背景:大概在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