如果预装了anaconda,在安装时,需要退出base环境,否则在make时,会报很多错误。
比如,下面这些错误,
make[2]: *** [apps/annotation/CMakeFiles/opencv_annotation.dir/build.make:89:bin/opencv_annotation] 错误 1
make[1]: *** [CMakeFiles/Makefile2:3014:apps/annotation/CMakeFiles/opencv_annotation.dir/all] 错误 2
/usr/bin/ld: /lib/x86_64-linux-gnu/libwayland-client.so.0: undefined reference to `ffi_type_uint32@LIBFFI_BASE_7.0'
/usr/bin/ld: /lib/x86_64-linux-gnu/libwayland-client.so.0: undefined reference to `ffi_type_sint32@LIBFFI_BASE_7.0'
/usr/bin/ld: /lib/x86_64-linux-gnu/libp11-kit.so.0: undefined reference to `ffi_closure_alloc@LIBFFI_CLOSURE_7.0'
/usr/bin/ld: /lib/x86_64-linux-gnu/libwayland-client.so.0: undefined reference to `ffi_call@LIBFFI_BASE_7.0'
/usr/bin/ld: /lib/x86_64-linux-gnu/libp11-kit.so.0: undefined reference to `ffi_type_uint8@LIBFFI_BASE_7.0'
/usr/bin/ld: /lib/x86_64-linux-gnu/libp11-kit.so.0: undefined reference to `ffi_prep_closure_loc@LIBFFI_CLOSURE_7.0'
/usr/bin/ld: /lib/x86_64-linux-gnu/libp11-kit.so.0: undefined reference to `ffi_type_uint64@LIBFFI_BASE_7.0'
/usr/bin/ld: /lib/x86_64-linux-gnu/libwayland-client.so.0: undefined reference to `ffi_type_pointer@LIBFFI_BASE_7.0'
/usr/bin/ld: /lib/x86_64-linux-gnu/libwayland-client.so.0: undefined reference to `ffi_type_void@LIBFFI_BASE_7.0'
/usr/bin/ld: /lib/x86_64-linux-gnu/libwayland-client.so.0: undefined reference to `ffi_prep_cif@LIBFFI_BASE_7.0'
collect2: error: ld returned 1 exit status
看上去是库的链接问题,但实际上是因为在base虚拟环境下。
在cmake过程,其实cmake文件也提示了和conda有关
-- Configuring done
CMake Warning at cmake/OpenCVUtils.cmake:1508 (add_library):
Cannot generate a safe runtime search path for target opencv_imgcodecs
because files in some directories may conflict with libraries in implicit
directories:
runtime library [libz.so.1] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
/home/hlg/anaconda3/lib
runtime library [libpng16.so.16] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
/home/hlg/anaconda3/lib
runtime library [libtiff.so.5] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
/home/hlg/anaconda3/lib
因此,在linux下安装了conda环境再安装c++的opnecv,一定要记得退出虚拟环境。
其他的安装,正常参考普通教程即可。
命令行安装教程
Ubuntu 20.04下搭建C++ & OpenCV 4.6.0 & cmake编译 - 知乎 (zhihu.com)
图形化安装过程
(238条消息) 【安装教程】Ubuntu18.04中用CMake-gui安装OpenCV4.1.0和OpenCV_contrib-4.1.0(图文)_wuyu1125的博客-优快云博客
另外,其他过程中下载文件的问题可参考
文章指出,在预装了Anaconda的情况下,安装OpenCV时需退出base环境,否则在使用make时可能会遇到库链接错误。这些错误通常涉及到ffi类型和库冲突。解决方案是确保不在conda的环境中执行编译过程。文章提供了Ubuntu系统下的C++和OpenCV安装教程链接,以及遇到下载文件问题的参考资源。
3161

被折叠的 条评论
为什么被折叠?



