前言:
Opencv 开源库的使用是必须的,但是,开源项目的特性,造成,版本的依赖性比较复杂,
尤其是针对某一款老硬件的SDK,往往随着某个开源库的使用,导致,无法编译的问题,
本文,就是在一个硬件的SDK中用到了opencv3.3的版本,在笔者目前的VS2019,CUDA11版本下编译的问题和解决。
结论:
1 出现编译错误不要慌,这是开源项目的正常正常现象
2 搞清楚现在的SDK是那年出来的
3 搞清楚哪个库出问题,去找一下这个库的原始网站或者GitHub,看一下这些年都有哪些更新,尤其是接口API是不是变了
4 网上找找有没有哪个兄弟也遇到了,并解决了
5 找不到,不要慌,把编译或者链接出错的库拿出来,在源文件夹的编译配置文件里面搜一下
6 学一点CMAKE的知识,看看是这个库的问题还是这个库依赖的库问题,一半Cmake比较准确,就是这个库问题
7 确认这个库的版本是不是和你的SDK要求的版本一致
8 确认源文件里面有没有这个库
9 找到这个缺失的库,或者,去掉这个库的编译连接配置,或者用-D 告诉编译器这个库你就别管了,都行,反正能让编译器保持继续工作就可以!
问题:
CUDA_nppicom_LIBRARY (ADVANCED)
错误信息如下:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
CUDA_nppicom_LIBRARY (ADVANCED)
linked by target "opencv_cudev" in directory D:/opencv331/opencv/sources/modules/cudev
linked by target "opencv_cudev" in directory D:/opencv331/opencv/sources/modules/cudev
linked by target "opencv_test_cudev" in directory D:/opencv331/opencv/sources/modules/cudev/test
linked by target "opencv_core" in directory D:/opencv331/opencv/sources/modules/core
linked by target "opencv_core" in directory D:/opencv331/opencv/sources/modules/core
linked by target "opencv_test_core" in directory D:/opencv331/opencv/sources/modules/core
linked by target "opencv_perf_core" in directory D:/opencv331/opencv/sources/modules/core
linked by target "opencv_flann" in directory D:/opencv331/opencv/sources/modules/flann
linked by target "opencv_flann" in directory D:/opencv331/opencv/sources/modules/flann
linked by target "opencv_test_flann" in directory D:/opencv331/opencv/sources/modules/flann
linked by target "opencv_perf_imgproc" in directory D:/opencv331/opencv/sources/modules/imgproc
linked by target "opencv_imgproc" in directory D:/opencv331/opencv/sources/modules/imgproc
linked by target "opencv_imgproc" in directory D:/opencv331/opencv/sources/modules/imgproc
linked by target "opencv_test_imgproc" in directory D:/opencv331/opencv/sources/modules/imgproc
linked by target "opencv_ml" in directory D:/opencv331/opencv/sources/modules/ml
linked by target "opencv_ml" in directory D:/opencv331/opencv/sources/modules/ml
linked by target "opencv_test_ml" in directory D:/opencv331/opencv/sources/modules/ml
linked by target "opencv_objdetect" in directory D:/opencv331/opencv/sources/modules/objdetect
linked by target "opencv_objdetect" in directory D:/opencv331/opencv/sources/modules/objdetect
linked by target "opencv_test_objdetect" in directory D:/opencv331/opencv/sources/modules/objdetect
linked by target "opencv_perf_objdetect" in directory D:/opencv331/opencv/sources/modules/objdetect
linked by target "opencv_photo" in directory D:/opencv331/opencv/sources/modules/photo
linked by target "opencv_photo" in directory D:/opencv331/opencv/sources/modules/photo
linked by target "opencv_test_photo" in directory D:/opencv331/opencv/sources/modules/photo
linked by target "opencv_perf_photo" in directory D:/opencv331/opencv/sources/modules/photo
linked by target "opencv_video" in directory D:/opencv331/opencv/sources/modules/video
linked by target "opencv_video" in directory D:/opencv331/opencv/sources/modules/video
linked by target "opencv_test_video" in directory D:/opencv331/opencv/sources/modules/video
linked by target "opencv_perf_video" in directory D:/opencv331/opencv/sources/modules/video
linked by target "opencv_dnn" in directory D:/opencv331/opencv/sources/modules/dnn
linked by target "opencv_dnn" in directory D:/opencv331/opencv/sources/modules/dnn
linked by target "opencv_test_dnn" in directory D:/opencv331/opencv/sources/modules/dnn
linked by target "opencv_perf_dnn" in directory D:/opencv331/opencv/sources/modules/dnn
linked by target "opencv_imgcodecs" in directory D:/opencv331/opencv/sources/modules/imgcodecs
linked by target "opencv_imgcodecs" in directory D:/opencv331/opencv/sources/modules/imgcodecs
linked by target "opencv_test_imgcodecs" in directory D:/opencv331/opencv/sources/modules/imgcodecs
linked by target "opencv_perf_imgcodecs" in directory D:/opencv331/opencv/sources/modules/imgcodecs
linked by target "opencv_shape" in directory D:/opencv331/opencv/sources/modules/shape
linked by target "opencv_shape" in directory D:/opencv331/opencv/sources/modules/shape
linked by target "opencv_test_shape" in directory D:/opencv331/opencv/sources/modules/shape
linked by target "opencv_videoio" in directory D:/opencv331/opencv/sources/modules/videoio
linked by target "opencv_videoio" in directory D:/opencv331/opencv/sources/modules/videoio
linked by target "opencv_test_videoio" in directory D:/opencv331/opencv/sources/modules/videoio
linked by target "opencv_perf_videoio" in directory D:/opencv331/opencv/sources/modules/videoio
linked by target "opencv_highgui" in directory D:/opencv331/opencv/sources/modules/highgui
linked by target "opencv_highgui" in directory D:/opencv331/opencv/sources/modules/highgui
linked by target "opencv_test_highgui" in directory D:/opencv331/opencv/sources/modules/highgui
linked by target "opencv_superres" in directory D:/opencv331/opencv/sources/modules/superres
linked by target "opencv_superres" in directory D:/opencv331/opencv/sources/modules/superres
linked by target "opencv_test_superres" in directory D:/opencv331/opencv/sources/modules/superres
linked by target "opencv_perf_superres" in directory D:/opencv331/opencv/sources/modules/superres
linked by target "opencv_ts" in directory D:/opencv331/opencv/sources/modules/ts
linked by target "opencv_ts" in directory D:/opencv331/opencv/sources/modules/ts
linked by target "opencv_features2d" in directory D:/opencv331/opencv/sources/modules/features2d
linked by target "opencv_features2d" in directory D:/opencv331/opencv/sources/modules/features2d
linked by target "opencv_test_features2d" in directory D:/opencv331/opencv/sources/modules/features2d
linked by target "opencv_perf_features2d" in directory D:/opencv331/opencv/sources/modules/features2d
linked by target "opencv_calib3d" in directory D:/opencv331/opencv/sources/modules/calib3d
linked by target "opencv_calib3d" in directory D:/opencv331/opencv/sources/modules/calib3d
linked by target "opencv_test_calib3d" in directory D:/opencv331/opencv/sources/modules/calib3d
linked by target "opencv_perf_calib3d" in directory D:/opencv331/opencv/sources/modules/calib3d
linked by target "opencv_stitching" in directory D:/opencv331/opencv/sources/modules/stitching
linked by target "opencv_stitching" in directory D:/opencv331/opencv/sources/modules/stitching
linked by target "opencv_test_stitching" in directory D:/opencv331/opencv/sources/modules/stitching
linked by target "opencv_perf_stitching" in directory D:/opencv331/opencv/sources/modules/stitching
linked by target "opencv_videostab" in directory D:/opencv331/opencv/sources/modules/videostab
linked by target "opencv_videostab" in directory D:/opencv331/opencv/sources/modules/videostab
linked by target "opencv_test_videostab" in directory D:/opencv331/opencv/sources/modules/videostab
linked by target "opencv_traincascade" in directory D:/opencv331/opencv/sources/apps/traincascade
linked by target "opencv_createsamples" in directory D:/opencv331/opencv/sources/apps/createsamples
linked by target "opencv_annotation" in directory D:/opencv331/opencv/sources/apps/annotation
linked by target "opencv_visualisation" in directory D:/opencv331/opencv/sources/apps/visualisation
linked by target "opencv_interactive-calibration" in directory D:/opencv331/opencv/sources/apps/interactive-calibration
linked by target "opencv_version" in directory D:/opencv331/opencv/sources/apps/versionGenerating done
解决办法:
1 问题分析
原因解析:
cuda9以上不再支持2.0架构,笔者系统的CUDA的版本是11.0,自然是没有这个nppicom的库的,所以,我们需求在配置中拿掉这个选项:
2 找到编译配置文件:
D:\opencv331\opencv\sources\cmake
【案,可以在source目录下,直接搜索报错的库名称,CUDA_nppicom_LIBRARY,也能找到makefile对应的修改的地方】
CUDA的配置在,
3 找到错误的库应用:
在文件,FindCUDA.cmake,我们做如下修改:
# Cuda not support nppicom from version 9 so just add a condition find_cuda_helper_libs(nppicom)if(CUDA_VERSION VERSION_LESS "11.0")find_cuda_helper_libs(nppicom)endif()find_cuda_helper_libs(nppidei)find_cuda_helper_libs(nppif)find_cuda_helper_libs(nppig)find_cuda_helper_libs(nppim)find_cuda_helper_libs(nppist)find_cuda_helper_libs(nppisu)find_cuda_helper_libs(nppitc)find_cuda_helper_libs(npps)if(CUDA_VERSION VERSION_LESS "11.0")set(CUDA_nppi_LIBRARY "${CUDA_nppial_LIBRARY};${CUDA_nppicc_LIBRARY};${CUDA_nppicom_LIBARY};${CUDA_nppidei_LIBRARY};${CUDA_nppif_LIBRARY};${CUDA_nppig_LIBRARY};${CUDA_nppim_LIBRARY};${CUDA_nppist_LIBRARY};${CUDA_nppisu_LIBRARY};${CUDA_nppitc_LIBRARY}")else()set(CUDA_nppi_LIBRARY "${CUDA_nppial_LIBRARY};${CUDA_nppicc_LIBRARY};${CUDA_nppidei_LIBRARY};${CUDA_nppif_LIBRARY};${CUDA_nppig_LIBRARY};${CUDA_nppim_LIBRARY};${CUDA_nppist_LIBRARY};${CUDA_nppisu_LIBRARY};${CUDA_nppitc_LIBRARY}")endif()
注意,
箭头处,都是笔者的修改
4 重新编译:
Configuring done
Generating done
就可以了
Ubuntu18.04+CUDA11.2+opencv4.3.0:CUDA_nppicom_LIBRARY (ADVANCED)报错解决_cuda_npps_library (advanced)-CSDN博客
OpenCV3.3+CUDA9.0+Cmake3.9 环境搭建_opencv make失败cuda compire-CSDN博客