ubuntu编译OpenCV错误

背景:大概在10%的时候有报错

[...cuda_compile_generated_gpu_mat.cu.o] Error 1

1 报错一: 错误的log大概如下

    make2: *
    [modules/core/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_gpu_mat.cu.o]
    Error 1 make1: [modules/core/CMakeFiles/opencv_core.dir/all] Error 2

类似情况网上比较多,例如这里

该情况应该是由于NVCC版本比较新引起的
解决办法:
是将下面这段语句加到Opencv根目录下的CMakeList文件的开头:

 set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -D_FORCE_INLINES”)

2 报错二: 但是在17%的位置再次报错:

/usr/bin/ld: CMakeFiles/opencv_core.dir/src/cuda_info.cpp.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
CMakeFiles/opencv_core.dir/src/cuda_info.cpp.o: 无法添加符号: 错误的值
collect2: error: ld returned 1 exit status
modules/core/CMakeFiles/opencv_core.dir/build.make:1254: recipe for target 'lib/libopencv_core.so.3.0.0' failed
make[2]: *** [lib/libopencv_core.so.3.0.0] Error 1
CMakeFiles/Makefile2:1535: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/all' failed
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2

出现问题的原因:
https://blog.csdn.net/u010312436/article/details/52486811

解决办法:
在CMakeLists.txt中添加如下一行:
add_definitions(-fPIC)
加上上文的set(...)也就是如下:
add_definitions(-fPIC)
set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -D_FORCE_INLINES”)

 

报错三:

/usr/bin/ld: warning: libzstd.so.1.3.7, needed by //home/nk/anaconda3/lib/libtiff.so.5, not found (try using -rpath or -rpath-link)
//home/nk/anaconda3/lib/libtiff.so.5:对‘ZSTD_initCStream’未定义的引用
//home/nk/anaconda3/lib/libtiff.so.5:对‘ZSTD_freeCStream’未定义的引用
//home/nk/anaconda3/lib/libtiff.so.5:对‘ZSTD_maxCLevel’未定义的引用
//home/nk/anaconda3/lib/libtiff.so.5:对‘ZSTD_createCStream’未定义的引用
//home/nk/anaconda3/lib/libtiff.so.5:对‘ZSTD_isError’未定义的引用
//home/nk/anaconda3/lib/libtiff.so.5:对‘ZSTD_getErrorName’未定义的引用
//home/nk/anaconda3/lib/libtiff.so.5:对‘ZSTD_endStream’未定义的引用
//home/nk/anaconda3/lib/libtiff.so.5:对‘ZSTD_createDStream’未定义的引用
//home/nk/anaconda3/lib/libtiff.so.5:对‘ZSTD_initDStream’未定义的引用
//home/nk/anaconda3/lib/libtiff.so.5:对‘ZSTD_freeDStream’未定义的引用
//home/nk/anaconda3/lib/libtiff.so.5:对‘ZSTD_compressStream’未定义的引用
//home/nk/anaconda3/lib/libtiff.so.5:对‘ZSTD_decompressStream’未定义的引用
collect2: error: ld returned 1 exit status
modules/cudev/test/CMakeFiles/opencv_test_cudev.dir/build.make:231: recipe for target 'bin/opencv_test_cudev' failed
make[2]: *** [bin/opencv_test_cudev] Error 1
CMakeFiles/Makefile2:1474: recipe for target 'modules/cudev/test/CMakeFiles/opencv_test_cudev.dir/all' failed
make[1]: *** [modules/cudev/test/CMakeFiles/opencv_test_cudev.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2

评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

计算机视觉-Archer

图像分割没有团队的同学可加群

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

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

打赏作者

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

抵扣说明:

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

余额充值