源码编译opencv可参考教程:在ubuntu下安装opencv4.1.0详细步骤icon-default.png?t=M4ADhttps://blog.csdn.net/weixin_44003563/article/details/90404745

在操作make -j8的时候报错如下:

[ 25%] Linking CXX executable ../../bin/opencv_annotation
/usr/bin/ld: ../../lib/libopencv_imgcodecs.so.4.5.0: undefined reference to "TIFFReadRGBAStrip@LIBTIFF_4.0"
/usr/bin/ld: ../../lib/libopencv_imgcodecs.so.4.5.0: undefined reference to "TIFFReadDirectory@LIBTIFF_4.0"
/usr/bin/ld: ../../lib/libopencv_imgcodecs.so.4.5.0: undefined reference to "TIFFWriteEncodedStrip@LIBTIFF_4.0"
/usr/bin/ld: ../../lib/libopencv_imgcodecs.so.4.5.0: undefined reference to "TIFFIsTiled@LIBTIFF_4.0"
/usr/bin/ld: ../../lib/libopencv_imgcodecs.so.4.5.0: undefined reference to "TIFFWriteScanline@LIBTIFF_4.0"
/usr/bin/ld: ../../lib/libopencv_imgcodecs.so.4.5.0: undefined reference to "TIFFGetField@LIBTIFF_4.0"
/usr/bin/ld: ../../lib/libopencv_imgcodecs.so.4.5.0: undefined reference to "TIFFScanlineSize@LIBTIFF_4.0"
/usr/bin/ld: ../../lib/libopencv_imgcodecs.so.4.5.0: undefined reference to "TIFFWriteDirectory@LIBTIFF_4.0"
/usr/bin/ld: ../../lib/libopencv_imgcodecs.so.4.5.0: undefined reference to "TIFFReadEncodedTile@LIBTIFF_4.0"
/usr/bin/ld: ../../lib/libopencv_imgcodecs.so.4.5.0: undefined reference to "TIFFReadRGBATile@LIBTIFF_4.0"
/usr/bin/ld: ../../lib/libopencv_imgcodecs.so.4.5.0: undefined reference to "TIFFClose@LIBTIFF_4.0"
/usr/bin/ld: ../../lib/libopencv_imgcodecs.so.4.5.0: undefined reference to "TIFFClientOpen@LIBTIFF_4.0"
/usr/bin/ld: ../../lib/libopencv_imgcodecs.so.4.5.0: undefined reference to "TIFFRGBAImageOK@LIBTIFF_4.0"
/usr/bin/ld: ../../lib/libopencv_imgcodecs.so.4.5.0: undefined reference to "TIFFOpen@LIBTIFF_4.0"
/usr/bin/ld: ../../lib/libopencv_imgcodecs.so.4.5.0: undefined reference to "TIFFReadEncodedStrip@LIBTIFF_4.0"
/usr/bin/ld: ../../lib/libopencv_imgcodecs.so.4.5.0: undefined reference to "TIFFSetField@LIBTIFF_4.0"
/usr/bin/ld: ../../lib/libopencv_imgcodecs.so.4.5.0: undefined reference to "TIFFSetWarningHandler@LIBTIFF_4.0"
/usr/bin/ld: ../../lib/libopencv_imgcodecs.so.4.5.0: undefined reference to "TIFFSetErrorHandler@LIBTIFF_4.0"
collect2: error: ld returned 1 exit status
make[2]: *** [apps/annotation/CMakeFiles/opencv_annotation.dir/build.make:95: bin/opencv_annotation] Erro 1
make[1]: *** [CMakeFiles/Makefile2:18408: apps/annotation/CMakeFiles/opencv_annotation.dir/all] Erro 2
make[1]: ** Waiting for other processes to finish.

对比cmake的时候也有警告:

-- 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/zhangsan/anaconda3/lib
    runtime library [libpng16.so.16] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /home/zhangsan/anaconda3/lib
    runtime library [libtiff.so.5] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /home/zhangsan/anaconda3/lib

参考Ubuntu中安装openCV3.4.12编译过程中与Anaconda冲突icon-default.png?t=M4ADhttps://blog.csdn.net/weixin_43592742/article/details/116612141并且在之前安装教程基础上,下载了opencv_contrib并放到opencv目录下,再次按照上述教程执行,就成功了

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐