ubnutu: 编译libtorch有关的代码时opencv报错-undefined reference to `TIFF**********@LIBTIFF_4.0‘

本文解决在编译YOLOv4过程中遇到的与TIFF相关的链接错误问题,提供了通过卸载Anaconda3中的libtiff库来修复的方法。

报错如下:

[ 25%] Linking CXX executable yolov4
/usr/local/lib/libopencv_world.so.3.4.10: undefined reference to `TIFFReadDirectory@LIBTIFF_4.0'
/usr/local/lib/libopencv_world.so.3.4.10: undefined reference to `TIFFWriteEncodedStrip@LIBTIFF_4.0'
/usr/local/lib/libopencv_world.so.3.4.10: undefined reference to `TIFFIsTiled@LIBTIFF_4.0'
/usr/local/lib/libopencv_world.so.3.4.10: undefined reference to `TIFFScanlineSize@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.3.so.6.3: undefined reference to `TIFFTileSize@LIBTIFF_4.0'
/usr/local/lib/libopencv_world.so.3.4.10: undefined reference to `TIFFRGBAImageOK@LIBTIFF_4.0'
/usr/local/lib/libopencv_world.so.3.4.10: undefined reference to `TIFFClose@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.3.so.6.3: undefined reference to `TIFFGetFieldDefaulted@LIBTIFF_4.0'
/usr/local/lib/libopencv_world.so.3.4.10: undefined reference to `TIFFSetWarningHandler@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.3.so.6.3: undefined reference to `_TIFFmalloc@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.3.so.6.3: undefined reference to `TIFFDefaultStripSize@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.3.so.6.3: undefined reference to `TIFFReadTile@LIBTIFF_4.0'
/usr/local/lib/libopencv_world.so.3.4.10: undefined reference to `TIFFWriteScanline@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.3.so.6.3: undefined reference to `_TIFFfree@LIBTIFF_4.0'
/usr/local/lib/libopencv_world.so.3.4.10: undefined reference to `TIFFGetField@LIBTIFF_4.0'
/usr/local/lib/libopencv_world.so.3.4.10: undefined reference to `TIFFWriteDirectory@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_generate@UUID_1.0'
/usr/local/lib/libopencv_world.so.3.4.10: undefined reference to `TIFFReadEncodedTile@LIBTIFF_4.0'
/usr/local/lib/libopencv_world.so.3.4.10: undefined reference to `TIFFReadRGBATile@LIBTIFF_4.0'
/usr/local/lib/libopencv_world.so.3.4.10: undefined reference to `TIFFClientOpen@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.3.so.6.3: undefined reference to `TIFFNumberOfDirectories@LIBTIFF_4.0'
/usr/local/lib/libopencv_world.so.3.4.10: undefined reference to `TIFFOpen@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.3.so.6.3: undefined reference to `TIFFReadRGBAImage@LIBTIFF_4.0'
/usr/local/lib/libopencv_world.so.3.4.10: undefined reference to `TIFFReadEncodedStrip@LIBTIFF_4.0'
/usr/local/lib/libopencv_world.so.3.4.10: undefined reference to `TIFFSetField@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_unparse_lower@UUID_1.0'
/usr/local/lib/libopencv_world.so.3.4.10: undefined reference to `TIFFSetErrorHandler@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.3.so.6.3: undefined reference to `TIFFSetDirectory@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.3.so.6.3: undefined reference to `TIFFReadScanline@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libvtkIOImage-6.3.so.6.3: undefined reference to `TIFFNumberOfTiles@LIBTIFF_4.0'
/usr/local/lib/libopencv_world.so.3.4.10: undefined reference to `TIFFReadRGBAStrip@LIBTIFF_4.0'
collect2: error: ld returned 1 exit status
CMakeFiles/yolov4.dir/build.make:178: recipe for target 'yolov4' failed
make[2]: *** [yolov4] Error 1
CMakeFiles/Makefile2:75: recipe for target 'CMakeFiles/yolov4.dir/all' failed
make[1]: *** [CMakeFiles/yolov4.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

解决方法:

不同的人可能解决方法不一样,先放上该问题有关的GitHub链接供大家查阅:

1、https://github.com/colmap/colmap/issues/188

2、https://github.com/lagadic/visp/issues/109

一般这个问题是由于已经安装的anaconda3的lib文件夹下的某些库文件与环境/usr/lib中的冲突了,在终端中运行以下命令即可解决问题:

conda uninstall libtiff

按照GitHub上说的解决方案,还有一种就是注释掉.bashrc中的anaconda的环境设置,在编译完之后再恢复,但是这种方法我用了没反应,所以就是用了上面说的那种方式。

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

地球被支点撬走啦

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值