Tag Archives: Opencv Compile Error

[Solved] Opencv Compile Error: (CMake Error: The following variables are used in this project, but they are set to not)

report errors

On Jetson NX, an error occurred while compiling opencv4.1.1. The error is as follows

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_cublas_LIBRARY (ADVANCED)
    linked by target "opencv_cudev" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudev
    linked by target "opencv_test_cudev" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudev/test
    linked by target "opencv_test_core" in directory /opt/opencv4/opencv-4.1.1/modules/core
    linked by target "opencv_perf_core" in directory /opt/opencv4/opencv-4.1.1/modules/core
    linked by target "opencv_core" in directory /opt/opencv4/opencv-4.1.1/modules/core
    linked by target "opencv_test_cudaarithm" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudaarithm
    linked by target "opencv_cudaarithm" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudaarithm
    linked by target "opencv_cudaarithm" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudaarithm
    linked by target "opencv_perf_cudaarithm" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudaarithm
    linked by target "opencv_flann" in directory /opt/opencv4/opencv-4.1.1/modules/flann
    linked by target "opencv_test_flann" in directory /opt/opencv4/opencv-4.1.1/modules/flann
    linked by target "opencv_perf_imgproc" in directory /opt/opencv4/opencv-4.1.1/modules/imgproc
    linked by target "opencv_test_imgproc" in directory /opt/opencv4/opencv-4.1.1/modules/imgproc
    linked by target "opencv_imgproc" in directory /opt/opencv4/opencv-4.1.1/modules/imgproc
    linked by target "opencv_test_ml" in directory /opt/opencv4/opencv-4.1.1/modules/ml
    linked by target "opencv_ml" in directory /opt/opencv4/opencv-4.1.1/modules/ml
    linked by target "opencv_test_phase_unwrapping" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/phase_unwrapping
    linked by target "opencv_phase_unwrapping" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/phase_unwrapping
    linked by target "opencv_plot" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/plot
    linked by target "opencv_test_quality" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/quality
    linked by target "opencv_quality" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/quality
    linked by target "opencv_test_reg" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/reg
    linked by target "opencv_reg" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/reg
    linked by target "opencv_perf_reg" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/reg
    linked by target "opencv_surface_matching" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/surface_matching
    linked by target "opencv_test_cudafilters" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudafilters
    linked by target "opencv_perf_cudafilters" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudafilters
    linked by target "opencv_cudafilters" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudafilters
    linked by target "opencv_test_cudaimgproc" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudaimgproc
    linked by target "opencv_cudaimgproc" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudaimgproc
    linked by target "opencv_perf_cudaimgproc" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudaimgproc
    linked by target "opencv_test_cudawarping" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudawarping
    linked by target "opencv_cudawarping" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudawarping
    linked by target "opencv_perf_cudawarping" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudawarping
    linked by target "opencv_dnn" in directory /opt/opencv4/opencv-4.1.1/modules/dnn
    linked by target "opencv_perf_dnn" in directory /opt/opencv4/opencv-4.1.1/modules/dnn
    linked by target "opencv_test_dnn" in directory /opt/opencv4/opencv-4.1.1/modules/dnn
    linked by target "opencv_features2d" in directory /opt/opencv4/opencv-4.1.1/modules/features2d
    linked by target "opencv_perf_features2d" in directory /opt/opencv4/opencv-4.1.1/modules/features2d
    linked by target "opencv_test_features2d" in directory /opt/opencv4/opencv-4.1.1/modules/features2d
    linked by target "opencv_test_fuzzy" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/fuzzy
    linked by target "opencv_fuzzy" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/fuzzy
    linked by target "opencv_hfs" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/hfs
    linked by target "opencv_test_img_hash" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/img_hash
    linked by target "opencv_img_hash" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/img_hash
    linked by target "opencv_imgcodecs" in directory /opt/opencv4/opencv-4.1.1/modules/imgcodecs
    linked by target "opencv_perf_imgcodecs" in directory /opt/opencv4/opencv-4.1.1/modules/imgcodecs
    linked by target "opencv_test_imgcodecs" in directory /opt/opencv4/opencv-4.1.1/modules/imgcodecs
    linked by target "opencv_test_line_descriptor" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/line_descriptor
    linked by target "opencv_perf_line_descriptor" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/line_descriptor
    linked by target "opencv_line_descriptor" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/line_descriptor
    linked by target "opencv_test_photo" in directory /opt/opencv4/opencv-4.1.1/modules/photo
    linked by target "opencv_photo" in directory /opt/opencv4/opencv-4.1.1/modules/photo
    linked by target "opencv_perf_photo" in directory /opt/opencv4/opencv-4.1.1/modules/photo
    linked by target "opencv_test_saliency" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/saliency
    linked by target "opencv_saliency" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/saliency
    linked by target "opencv_test_videoio" in directory /opt/opencv4/opencv-4.1.1/modules/videoio
    linked by target "opencv_videoio" in directory /opt/opencv4/opencv-4.1.1/modules/videoio
    linked by target "opencv_perf_videoio" in directory /opt/opencv4/opencv-4.1.1/modules/videoio
    linked by target "opencv_test_xphoto" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/xphoto
    linked by target "opencv_perf_xphoto" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/xphoto
    linked by target "opencv_xphoto" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/xphoto
    linked by target "opencv_calib3d" in directory /opt/opencv4/opencv-4.1.1/modules/calib3d
    linked by target "opencv_perf_calib3d" in directory /opt/opencv4/opencv-4.1.1/modules/calib3d
    linked by target "opencv_test_calib3d" in directory /opt/opencv4/opencv-4.1.1/modules/calib3d
    linked by target "opencv_test_cudacodec" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudacodec
    linked by target "opencv_cudacodec" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudacodec
    linked by target "opencv_perf_cudacodec" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudacodec
    linked by target "opencv_test_cudafeatures2d" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudafeatures2d
    linked by target "opencv_cudafeatures2d" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudafeatures2d
    linked by target "opencv_perf_cudafeatures2d" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudafeatures2d
    linked by target "opencv_test_cudastereo" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudastereo
    linked by target "opencv_cudastereo" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudastereo
    linked by target "opencv_perf_cudastereo" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudastereo
    linked by target "opencv_test_highgui" in directory /opt/opencv4/opencv-4.1.1/modules/highgui
    linked by target "opencv_highgui" in directory /opt/opencv4/opencv-4.1.1/modules/highgui
    linked by target "opencv_test_objdetect" in directory /opt/opencv4/opencv-4.1.1/modules/objdetect
    linked by target "opencv_objdetect" in directory /opt/opencv4/opencv-4.1.1/modules/objdetect
    linked by target "opencv_perf_objdetect" in directory /opt/opencv4/opencv-4.1.1/modules/objdetect
    linked by target "opencv_rgbd" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/rgbd
    linked by target "opencv_test_rgbd" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/rgbd
    linked by target "opencv_test_shape" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/shape
    linked by target "opencv_shape" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/shape
    linked by target "opencv_test_structured_light" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/structured_light
    linked by target "opencv_structured_light" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/structured_light
    linked by target "opencv_text" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/text
    linked by target "opencv_test_text" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/text
    linked by target "opencv_ts" in directory /opt/opencv4/opencv-4.1.1/modules/ts
    linked by target "opencv_video" in directory /opt/opencv4/opencv-4.1.1/modules/video
    linked by target "opencv_perf_video" in directory /opt/opencv4/opencv-4.1.1/modules/video
    linked by target "opencv_test_video" in directory /opt/opencv4/opencv-4.1.1/modules/video
    linked by target "opencv_xfeatures2d" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/xfeatures2d
    linked by target "opencv_perf_xfeatures2d" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/xfeatures2d
    linked by target "opencv_test_xfeatures2d" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/xfeatures2d
    linked by target "opencv_perf_ximgproc" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/ximgproc
    linked by target "opencv_ximgproc" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/ximgproc
    linked by target "opencv_test_ximgproc" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/ximgproc
    linked by target "opencv_xobjdetect" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/xobjdetect
    linked by target "opencv_test_aruco" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/aruco
    linked by target "opencv_aruco" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/aruco
    linked by target "opencv_bgsegm" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/bgsegm
    linked by target "opencv_test_bgsegm" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/bgsegm
    linked by target "opencv_test_bioinspired" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/bioinspired
    linked by target "opencv_perf_bioinspired" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/bioinspired
    linked by target "opencv_bioinspired" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/bioinspired
    linked by target "opencv_ccalib" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/ccalib
    linked by target "opencv_test_cudabgsegm" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudabgsegm
    linked by target "opencv_cudabgsegm" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudabgsegm
    linked by target "opencv_perf_cudabgsegm" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudabgsegm
    linked by target "opencv_test_cudalegacy" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudalegacy
    linked by target "opencv_cudalegacy" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudalegacy
    linked by target "opencv_perf_cudalegacy" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudalegacy
    linked by target "opencv_test_cudaobjdetect" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudaobjdetect
    linked by target "opencv_perf_cudaobjdetect" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudaobjdetect
    linked by target "opencv_cudaobjdetect" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudaobjdetect
    linked by target "opencv_datasets" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/datasets
    linked by target "opencv_dnn_objdetect" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/dnn_objdetect
    linked by target "opencv_dpm" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/dpm
    linked by target "opencv_test_face" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/face
    linked by target "opencv_face" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/face
    linked by target "opencv_test_optflow" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/optflow
    linked by target "opencv_optflow" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/optflow
    linked by target "opencv_perf_optflow" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/optflow
    linked by target "opencv_stitching" in directory /opt/opencv4/opencv-4.1.1/modules/stitching
    linked by target "opencv_test_tracking" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/tracking
    linked by target "opencv_tracking" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/tracking
    linked by target "opencv_perf_tracking" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/tracking
    linked by target "opencv_cudaoptflow" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudaoptflow
    linked by target "opencv_perf_cudaoptflow" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudaoptflow
    linked by target "opencv_test_cudaoptflow" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/cudaoptflow
    linked by target "opencv_test_stereo" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/stereo
    linked by target "opencv_stereo" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/stereo
    linked by target "opencv_perf_stereo" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/stereo
    linked by target "opencv_test_superres" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/superres
    linked by target "opencv_superres" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/superres
    linked by target "opencv_perf_superres" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/superres
    linked by target "opencv_test_videostab" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/videostab
    linked by target "opencv_videostab" in directory /opt/opencv4/opencv_contrib-4.1.1/modules/videostab
    linked by target "opencv_annotation" in directory /opt/opencv4/opencv-4.1.1/apps/annotation
    linked by target "opencv_visualisation" in directory /opt/opencv4/opencv-4.1.1/apps/visualisation
    linked by target "opencv_interactive-calibration" in directory /opt/opencv4/opencv-4.1.1/apps/interactive-calibration
    linked by target "opencv_version" in directory /opt/opencv4/opencv-4.1.1/apps/version

-- Configuring incomplete, errors occurred!
See also "/opt/opencv4/opencv-4.1.1/build/CMakeFiles/CMakeOutput.log".
See also "/opt/opencv4/opencv-4.1.1/build/CMakeFiles/CMakeError.log".

Solution

This is due to the lack of CUDA files.

Since I am CUDA 10.2, I choose cuda-toolkit-10-2 and the corresponding cuda-toolkit-x-x according to CUDA version. We install it directly, and the missing files will be downloaded and installed automatically,

sudo apt-get update
sudo apt-get install cuda-toolkit-10-2

After installation, recompile opnecv.