opencv库移植

一、如何获得opencv3.3源码?

    opencv官网    :https://opencv.org/opencv-3-3.html
    github opencv :https://github.com/opencv/opencv/releases/tag/3.3.0

二、交叉编译

    参考以下网址:
    https://www.cnblogs.com/emouse/archive/2013/04/01/2993842.html
    https://blog.csdn.net/gatieme/article/details/49080355

三、出现的错误问题

    3.1 -fPIC
    
        问题:R_AARCH64_ADR_PREL_PG_HI21重定向于符号__stack_chk_guard@GLIBC_2.17
        
        修改:opencv-3.3.0/build/CMakeCache.txt
        CMAKE_CXX_FLAGS:STRING=-fPIC
        CMAKE_C_FLAGS:STRING=-fPIC  
    
        参考以下网址:
        https://blog.csdn.net/wmjhzm220/article/details/78651988
        https://blog.csdn.net/derkampf/article/details/69660050
    
    3.2 NEON
    
        问题:undefined reference to `png_init_filter_functions_neon'
        
        修改:opencv-3.3.0/3rdparty/libpng/CMakeLists.txt
        set(ENABLE_NEON ON)
        set(AARCH64 ON)
        
        if(ARM OR AARCH64)
        #  if(ENABLE_NEON AND NOT AARCH64)
           if(ENABLE_NEON)
             list(APPEND lib_srcs arm/arm_init.c arm/filter_neon.S arm/filter_neon_intrinsics.c)
             add_definitions(-DPNG_ARM_NEON_OPT=2)
           else()
             add_definitions(-DPNG_ARM_NEON_OPT=0) # NEON assembler is not supported
           endif()
        endif()
    
        参考以下网址:
        https://blog.csdn.net/zhoudekuai/article/details/62425566
        https://github.com/opencv/opencv/issues/7600
    
    3.3 -lpthread
    
        问题:对‘pthread_create’未定义的引用
        
        修改:opencv-3.3.0/build/CMakeCache.txt
        CMAKE_EXE_LINKER_FLAGS:STRING= -lpthread -ldl
        
        注意:链接动态库时,需要放在最后。
              通过cmake进行配置后,-lpthread -ldl默认没有放在最后,需要手动修改。
              通过grep查找EXE文件在哪一个目录进行链接,然后在此目录修改link.txt文件,将-lpthread -ldl放在最后,即可。
        
        
        参考以下网址:
        https://blog.csdn.net/killwho/article/details/53785910
        https://bbs.csdn.net/topics/390785794
    
    3.4 rpath
    
        问题:动态库存在,并且使用-L指向目录,但是动态库not found ,提示使用-rpath
        
        参考以下网址:
        https://www.cnblogs.com/homejim/p/8004883.html
        https://www.cnblogs.com/candl/p/7358384.html
        https://blog.csdn.net/jmppok/article/details/17118669
        
       

你可能感兴趣的:(linux杂项)