cmake cannot find -lopencv_dep_cudart

when i compile the code, i got this error, it seems like trying to get a Runtime library which i cannot find in directory, i added set(CUDA_USE_STATIC_CUDA_RUNTIME OFF) in the CmakeLists.txt but it’s not working. How do i include this opencv_dep_cudart in cmakelists?

i can see and libcudart_static.a are in the lib64

Maybe some dependent lib wasn’t installed.

sudo apt-get install build-essential cmake git pkg-config

sudo apt-get install libjpeg8-dev libtiff5-dev libjasper-dev libpng12-dev

sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev

sudo apt-get install libgtk2.0-dev

sudo apt-get install libatlas-base-dev gfortran

sudo apt-get install python3-cairocffi

And then rebuild the opencv:

cmake -D WITH_CUDA=ON \
    -D WITH_CUBLAS=1 \
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules ~/opencv \
    -D CMAKE_INSTALL_PREFIX=/usr/local ..

sudo make -j4
sudo make install

Hi lucas:
I downloaded Opencv in home directory
cd ~/opencv
mkdir build
cd build

In which directory should I run “cmake -D WITH_CUDA[…]” ?

Thanks! I just tried, I reinstalled those libraries and dpkg the opencv4tegra, but still the same, is there some special way to just specific add that opencv_dep_cudart?

Would you please provide the detailed log/program you wanna compile?
I do not know which program need lib opencv_dep_cudart.


Same issue here

/usr/bin/ld: cannot find -lopencv_dep_cudart
collect2: error: ld returned 1 exit status
CMakeFiles/test.dir/build.make:174: recipe for target 'helloworld' failed
make[2]: *** [REMOVED ] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/REMOVED.dir/all' failed
make[1]: *** [CMakeFiles/test.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

This is working fine, before i flashed.

cmake_minimum_required(VERSION 2.8)

project( Helloworld )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

find_package(OpenCV REQUIRED)

    -O3 -gencode arch=compute_53,code=sm_53

include_directories(/usr/include/glib-2.0 /usr/include/libxml2 /usr/lib/aarch64-linux-gnu/glib-2.0/include/)

add_executable( helloworld hello.cpp hello1.cpp)
target_link_libraries( helloworld  ${OpenCV_LIBS})

This seems working for me

ln -s /usr/local/cuda8-0/lib64/ /usr/local/lib/
ln -s /usr/local/cuda8-0/lib64/libcudart.a /usr/local/lib/


But code cannot compiled if I don’t use STATIC CUDA RUNTIME

I have similar problem, when i am trying to build openvx_tutorial in qt creator , where can I set(CUDA_USE_STATIC…) also i installed opencv4tegra in my Jetson not the simple opencv so do i still need to install these dependencies mentioned by @gary ?

The actual problem is that ld is asking for “-lopencv_dep_cudart”
There is no library named “opencv_dep_cudart.”
There may be a pkg-config or cmake token named opencv_dep_cudart, which is supposed to resolve to the appropriate .so file, but that’s not happening here.
The bug is not in the paths or search paths for; the bug is in the cmake build system support files for cuda, or perhaps with how your CMakeFile.txt is set up (but I’ve seen correct CMakeFiles break like this.)

A short-term hack that fixes this for me is the following patch:

--- /tmp/unpatched      2017-07-27 05:35:44.164961655 +0000
+++ /usr/share/OpenCV/OpenCVConfig.cmake        2017-07-27 05:34:06.129390969 +0000
@@ -281,6 +281,11 @@
       set_target_properties("opencv_dep_${_tmp}" PROPERTIES IMPORTED_LOCATION "${l}")
+  # HACK jwatte 2017-07-26 trying to find the dynamic library
+  add_library("opencv_dep_cudart" UNKNOWN IMPORTED)
+  set_target_properties("opencv_dep_cudart" PROPERTIES IMPORTED_LOCATION /usr/local/cuda-8.0/targets/aarch64-linux/lib/

 # ==============================================================

You have to add “set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)” in CMakeLists.txt,
or code in shell as this : cmake -DCUDA_USE_STATIC_CUDA_RUNTIME=OFF

For Openvx tutorial after setting the syntax in CMAke file, I got no error except, video cannot open. Since it has an output video which it is not able to open. What could be the reason behind this ?

Hi Eyshika,

Do you want to use OpenCV or OpenVX?

Aastha, I specifically want to use Openvx in jetson so i started learning it from Openvx_tutorial but when it didnt run, i started working on Opencv. but my preference is Openvx, also i would like to have some good material related to openvx to learn it if you know. that would be greatfor me.


We have lots of samples to demonstrate OpenVX. (We call this VisionWorks API, specifying for Nvidia implementation)

Please install VisionWorks with JetPack directly.
Samples are located at /usr/share/visionworks/sources.

Most samples contain video decoder, for example, demos/feature_tracker.

Hi I have already installed Visionworks in jetpack after that only I clone openvx_tutorial and got the error. also I ran the visionwork samples they are running perfectly but i am not able to create something on my own also not able to run openvx_tutorial code.


Please share OpenVX sample and error message for us debugging.
One possible reason is not correctly linking to VisionWorks libraries.
Please check this topic: