Failure linking cuda libraries when compiling opencv

We have been attempting to compile opencv with cuda support on the Jetson Orin:
Linux Artax 5.10.104-tegra #1 SMP PREEMPT Wed Aug 10 20:17:07 PDT 2022 aarch64 aarch64 aarch64 GNU/Linux cuda 11.7

We have used several in-house scrips that usually work in addition to the following:

All techniques fail with the same symptoms:
Target “simple_pipeline” links to target “CUDA::cusparse” but the target
was not found.
Target “simple_pipeline” links to target “CUDA::cusolver” but the target
was not found.
Target “simple_pipeline” links to target “CUDA::cudart” but the target was
not found.
Target “simple_pipeline” links to target “CUDA::cublas” but the target was
not found.

Stack:

CMake Error at /usr/src/workspace/opencv-4.6.0/cmake/OpenCVUtils.cmake:1547 (add_library):
Target “opencv_sfm” links to target “CUDA::cublas” but the target was not
found. Perhaps a find_package() call is missing for an IMPORTED target, or
an ALIAS target is missing?
Call Stack (most recent call first):
/usr/src/workspace/opencv-4.6.0/cmake/OpenCVModule.cmake:966 (ocv_add_library)
/usr/src/workspace/opencv-4.6.0/cmake/OpenCVModule.cmake:882 (_ocv_create_module)
/usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/CMakeLists.txt:150 (ocv_create_module)

CMake Error at /usr/src/workspace/opencv-4.6.0/cmake/OpenCVUtils.cmake:1547 (add_library):
Target “opencv_sfm” links to target “CUDA::cudart” but the target was not
found. Perhaps a find_package() call is missing for an IMPORTED target, or
an ALIAS target is missing?
Call Stack (most recent call first):
/usr/src/workspace/opencv-4.6.0/cmake/OpenCVModule.cmake:966 (ocv_add_library)
/usr/src/workspace/opencv-4.6.0/cmake/OpenCVModule.cmake:882 (_ocv_create_module)
/usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/CMakeLists.txt:150 (ocv_create_module)

CMake Error at /usr/src/workspace/opencv-4.6.0/cmake/OpenCVUtils.cmake:1547 (add_library):
Target “opencv_sfm” links to target “CUDA::cusolver” but the target was not
found. Perhaps a find_package() call is missing for an IMPORTED target, or
an ALIAS target is missing?
Call Stack (most recent call first):
/usr/src/workspace/opencv-4.6.0/cmake/OpenCVModule.cmake:966 (ocv_add_library)
/usr/src/workspace/opencv-4.6.0/cmake/OpenCVModule.cmake:882 (_ocv_create_module)
/usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/CMakeLists.txt:150 (ocv_create_module)

CMake Error at /usr/src/workspace/opencv-4.6.0/cmake/OpenCVUtils.cmake:1547 (add_library):
Target “opencv_sfm” links to target “CUDA::cusparse” but the target was not
found. Perhaps a find_package() call is missing for an IMPORTED target, or
an ALIAS target is missing?
Call Stack (most recent call first):
/usr/src/workspace/opencv-4.6.0/cmake/OpenCVModule.cmake:966 (ocv_add_library)
/usr/src/workspace/opencv-4.6.0/cmake/OpenCVModule.cmake:882 (_ocv_create_module)
/usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/CMakeLists.txt:150 (ocv_create_module)

CMake Error at /usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/src/libmv_light/libmv/correspondence/CMakeLists.txt:9 (ADD_LIBRARY):
Target “correspondence” links to target “CUDA::cublas” but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?

CMake Error at /usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/src/libmv_light/libmv/correspondence/CMakeLists.txt:9 (ADD_LIBRARY):
Target “correspondence” links to target “CUDA::cudart” but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?

CMake Error at /usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/src/libmv_light/libmv/correspondence/CMakeLists.txt:9 (ADD_LIBRARY):
Target “correspondence” links to target “CUDA::cusolver” but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?

CMake Error at /usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/src/libmv_light/libmv/correspondence/CMakeLists.txt:9 (ADD_LIBRARY):
Target “correspondence” links to target “CUDA::cusparse” but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?

CMake Error at /usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/src/libmv_light/libmv/multiview/CMakeLists.txt:19 (ADD_LIBRARY):
Target “multiview” links to target “CUDA::cublas” but the target was not
found. Perhaps a find_package() call is missing for an IMPORTED target, or
an ALIAS target is missing?

CMake Error at /usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/src/libmv_light/libmv/multiview/CMakeLists.txt:19 (ADD_LIBRARY):
Target “multiview” links to target “CUDA::cudart” but the target was not
found. Perhaps a find_package() call is missing for an IMPORTED target, or
an ALIAS target is missing?

CMake Error at /usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/src/libmv_light/libmv/multiview/CMakeLists.txt:19 (ADD_LIBRARY):
Target “multiview” links to target “CUDA::cusolver” but the target was not
found. Perhaps a find_package() call is missing for an IMPORTED target, or
an ALIAS target is missing?

CMake Error at /usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/src/libmv_light/libmv/multiview/CMakeLists.txt:19 (ADD_LIBRARY):
Target “multiview” links to target “CUDA::cusparse” but the target was not
found. Perhaps a find_package() call is missing for an IMPORTED target, or
an ALIAS target is missing?

CMake Error at /usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/src/libmv_light/libmv/simple_pipeline/CMakeLists.txt:18 (ADD_LIBRARY):
Target “simple_pipeline” links to target “CUDA::cublas” but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?

CMake Error at /usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/src/libmv_light/libmv/simple_pipeline/CMakeLists.txt:18 (ADD_LIBRARY):
Target “simple_pipeline” links to target “CUDA::cudart” but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?

CMake Error at /usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/src/libmv_light/libmv/simple_pipeline/CMakeLists.txt:18 (ADD_LIBRARY):
Target “simple_pipeline” links to target “CUDA::cusolver” but the target
was not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?

CMake Error at /usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/src/libmv_light/libmv/simple_pipeline/CMakeLists.txt:18 (ADD_LIBRARY):
Target “simple_pipeline” links to target “CUDA::cusparse” but the target
was not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?

CMake Error at /usr/src/workspace/opencv-4.6.0/cmake/OpenCVUtils.cmake:1547 (add_library):
Target “opencv_sfm” links to target “CUDA::cublas” but the target was not
found. Perhaps a find_package() call is missing for an IMPORTED target, or
an ALIAS target is missing?
Call Stack (most recent call first):
/usr/src/workspace/opencv-4.6.0/cmake/OpenCVModule.cmake:966 (ocv_add_library)
/usr/src/workspace/opencv-4.6.0/cmake/OpenCVModule.cmake:882 (_ocv_create_module)
/usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/CMakeLists.txt:150 (ocv_create_module)

CMake Error at /usr/src/workspace/opencv-4.6.0/cmake/OpenCVUtils.cmake:1547 (add_library):
Target “opencv_sfm” links to target “CUDA::cudart” but the target was not
found. Perhaps a find_package() call is missing for an IMPORTED target, or
an ALIAS target is missing?
Call Stack (most recent call first):
/usr/src/workspace/opencv-4.6.0/cmake/OpenCVModule.cmake:966 (ocv_add_library)
/usr/src/workspace/opencv-4.6.0/cmake/OpenCVModule.cmake:882 (_ocv_create_module)
/usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/CMakeLists.txt:150 (ocv_create_module)

CMake Error at /usr/src/workspace/opencv-4.6.0/cmake/OpenCVUtils.cmake:1547 (add_library):
Target “opencv_sfm” links to target “CUDA::cusolver” but the target was not
found. Perhaps a find_package() call is missing for an IMPORTED target, or
an ALIAS target is missing?
Call Stack (most recent call first):
/usr/src/workspace/opencv-4.6.0/cmake/OpenCVModule.cmake:966 (ocv_add_library)
/usr/src/workspace/opencv-4.6.0/cmake/OpenCVModule.cmake:882 (_ocv_create_module)
/usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/CMakeLists.txt:150 (ocv_create_module)

CMake Error at /usr/src/workspace/opencv-4.6.0/cmake/OpenCVUtils.cmake:1547 (add_library):
Target “opencv_sfm” links to target “CUDA::cusparse” but the target was not
found. Perhaps a find_package() call is missing for an IMPORTED target, or
an ALIAS target is missing?
Call Stack (most recent call first):
/usr/src/workspace/opencv-4.6.0/cmake/OpenCVModule.cmake:966 (ocv_add_library)
/usr/src/workspace/opencv-4.6.0/cmake/OpenCVModule.cmake:882 (_ocv_create_module)
/usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/CMakeLists.txt:150 (ocv_create_module)

CMake Error at /usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/src/libmv_light/libmv/correspondence/CMakeLists.txt:9 (ADD_LIBRARY):
Target “correspondence” links to target “CUDA::cublas” but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?

CMake Error at /usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/src/libmv_light/libmv/correspondence/CMakeLists.txt:9 (ADD_LIBRARY):
Target “correspondence” links to target “CUDA::cudart” but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?

CMake Error at /usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/src/libmv_light/libmv/correspondence/CMakeLists.txt:9 (ADD_LIBRARY):
Target “correspondence” links to target “CUDA::cusolver” but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?

CMake Error at /usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/src/libmv_light/libmv/correspondence/CMakeLists.txt:9 (ADD_LIBRARY):
Target “correspondence” links to target “CUDA::cusparse” but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?

CMake Error at /usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/src/libmv_light/libmv/multiview/CMakeLists.txt:19 (ADD_LIBRARY):
Target “multiview” links to target “CUDA::cublas” but the target was not
found. Perhaps a find_package() call is missing for an IMPORTED target, or
an ALIAS target is missing?

CMake Error at /usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/src/libmv_light/libmv/multiview/CMakeLists.txt:19 (ADD_LIBRARY):
Target “multiview” links to target “CUDA::cudart” but the target was not
found. Perhaps a find_package() call is missing for an IMPORTED target, or
an ALIAS target is missing?

CMake Error at /usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/src/libmv_light/libmv/multiview/CMakeLists.txt:19 (ADD_LIBRARY):
Target “multiview” links to target “CUDA::cusolver” but the target was not
found. Perhaps a find_package() call is missing for an IMPORTED target, or
an ALIAS target is missing?

CMake Error at /usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/src/libmv_light/libmv/multiview/CMakeLists.txt:19 (ADD_LIBRARY):
Target “multiview” links to target “CUDA::cusparse” but the target was not
found. Perhaps a find_package() call is missing for an IMPORTED target, or
an ALIAS target is missing?

CMake Error at /usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/src/libmv_light/libmv/simple_pipeline/CMakeLists.txt:18 (ADD_LIBRARY):
Target “simple_pipeline” links to target “CUDA::cublas” but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?

CMake Error at /usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/src/libmv_light/libmv/simple_pipeline/CMakeLists.txt:18 (ADD_LIBRARY):
Target “simple_pipeline” links to target “CUDA::cudart” but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?

CMake Error at /usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/src/libmv_light/libmv/simple_pipeline/CMakeLists.txt:18 (ADD_LIBRARY):
Target “simple_pipeline” links to target “CUDA::cusolver” but the target
was not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?

CMake Error at /usr/src/workspace/opencv_contrib-4.6.0/modules/sfm/src/libmv_light/libmv/simple_pipeline/CMakeLists.txt:18 (ADD_LIBRARY):
Target “simple_pipeline” links to target “CUDA::cusparse” but the target
was not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?

Contents of /usr/local/cuda/lib64:
image

How we usually configure our environment variables:
export PKG_CONFIG_PATH=/usr/src/opencv-4.6.0/build/unix-install
export PATH=$PATH:/usr/lib/x86_64-linux-gnu/
export CUDA_HOME=/usr/local/cuda
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64
export PATH=$PATH:$CUDA_HOME/bin:/usr/include/python3.9

Make fails at 94% - modules/python/src2/cv2.cpp:6:20 - Python.h: No such file or directory · Issue #6464 · opencv/opencv · GitHub

export CPLUS_INCLUDE_PATH=$(python3 -c “from distutils.sysconfig import get_python_inc; print(get_python_inc())”)

I was able to work-around this issue by disabling the Structure from Motion module. I suppose the implications of this action will be discovered shortly as I am not precisely aware of how it will alter the behavior.

-D BUILD_opencv_sfm=OFF

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.