常见错误:
1.无法解决 R_AARCH64_ADR_PREL_PG_HI21 重定向于符号 “_ZNSt8ios_base7failureB5cxx11D1Ev@@GLIBCXX_3.4.21” 有冲突
2.../../lib/libopencv_core.so:对‘pthread_mutexattr_destroy’未定义的引用
../../lib/libopencv_core.so:对‘pthread_key_create’未定义的引用
../../lib/libopencv_core.so:对‘pthread_getspecific’未定义的引用
../../lib/libopencv_core.so:对‘dlopen’未定义的引用
../../lib/libopencv_core.so:对‘pthread_mutex_trylock’未定义的引用
../../lib/libopencv_core.so:对‘pthread_key_delete’未定义的引用
../../lib/libopencv_core.so:对‘dlclose’未定义的引用
../../lib/libopencv_core.so:对‘dlsym’未定义的引用
../../lib/libopencv_core.so:对‘pthread_mutexattr_settype’未定义的引用
../../lib/libopencv_core.so:对‘pthread_setspecific’未定义的引用
../../lib/libopencv_core.so:对‘pthread_mutexattr_init’未定义的引用
collect2: error: ld returned 1 exit status
apps/version/CMakeFiles/opencv_version.dir/build.make:95: recipe for target 'bin/opencv_version' failed
make[2]: *** [bin/opencv_version] Error 1
CMakeFiles/Makefile2:8366: recipe for target 'apps/version/CMakeFiles/opencv_version.dir/all' failed
make[1]: *** [apps/version/CMakeFiles/opencv_version.dir/all] Error 2
此问题就是因为没有设置CMAKE_EXE_LINKER_FLAGS项造成的,所以首先我们要修改编译目录下面的CMakeCache.txt的文件,在文件中找到CMAKE_EXE_LINKER_FLAGS 这一项,改为
//Flags used by the linker.
CMAKE_EXE_LINKER_FLAGS:STRING=-pthread -ldl -lrt
3.出现错误 “ libopencv_imgcodecs.so:对‘png_init_filter_functions_neon’未定义的引用 ”
根据 https://sourceforge.net/p/libpng/bugs/230/ 所发的补丁文件进行文件的修改并重新make就可以解决。注意补丁中有两个文件,只需要修改pngpriv.h 就可以,所以可以删除掉文件中关于configure.ac的部分。
具体如何使用patch,网上资料很多可以自行查看
也可以手动修改。
打开/opencv-4.1.2/3rdparty/libpng/pngpriv.h
将130行起的
# if (defined(__ARM_NEON__) || defined(__ARM_NEON)) && \
131 defined(PNG_ALIGNED_MEMORY_SUPPORTED)
改为
# if defined(PNG_ARM_NEON) && (defined(__ARM_NEON__) || defined(__ARM_NEON)) && \
defined(PNG_ALIGNED_MEMORY_SUPPORTED)
4.
/opencv_contrib/modules/xfeatures2d/src/boostdesc.cpp:653:37: fatal error: boostdesc_bgm.i: No such file or directory
#include "boostdesc_bgm.i"
^
compilation terminated.
modules/xfeatures2d/CMakeFiles/opencv_xfeatures2d.dir/build.make:91: recipe for target 'modules/xfeatures2d/CMakeFiles/opencv_xfeatures2d.dir/src/boostdesc.cpp.obj' failed
make[2]: *** [modules/xfeatures2d/CMakeFiles/opencv_xfeatures2d.dir/src/boostdesc.cpp.obj] Error 1
这是因为缺失的文件下载失败或者缺失,可以将一系列库文件复制到opencv_contrib/modules/xfeatures2d/src 中,即可解决,下载地址可以自行查找或在下载频道我有上传
https://download.csdn.net/download/qq_34533248/11804560
参考链接:
使用海思的交叉编译器编译opencv的过程中遇到的问题_他们叫我高老师的博客-CSDN博客
Linux OpenCV交叉编译20220322_songlixiangaibin的博客-CSDN博客_linux opencv 交叉编译
Linux OpenCV交叉编译20220322_songlixiangaibin的博客-CSDN博客_linux opencv 交叉编译