# cmake cannot find -lopencv\_dep\_cudart

**URL:** <https://forums.developer.nvidia.com/t/cmake-cannot-find-lopencv-dep-cudart/45392>\
**Category:** Jetson TX1\
**Created:** [October 7, 2016, 5:23pm UTC](https://forums.developer.nvidia.com/t/cmake-cannot-find-lopencv-dep-cudart/45392 "2016-10-07T17:23:19Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gary\_4001](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/gary_4001/32/12639_2.png) [@Gary\_4001](https://forums.developer.nvidia.com/u/Gary_4001)\
**Post date:** [October 7, 2016, 5:23pm UTC](https://forums.developer.nvidia.com/t/cmake-cannot-find-lopencv-dep-cudart/45392/1 "2016-10-07T17:23:19Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Gary\_4001](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/gary_4001/32/12639_2.png) [@Gary\_4001](https://forums.developer.nvidia.com/u/Gary_4001)\
**Post date:** [October 7, 2016, 5:25pm UTC](https://forums.developer.nvidia.com/t/cmake-cannot-find-lopencv-dep-cudart/45392/2 "2016-10-07T17:25:33Z")

</div>

i can see libcudart.so and libcudart\_static.a are in the lib64

---

<div class="post-metadata">

**Author:** ![TimCook](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@TimCook](https://forums.developer.nvidia.com/u/TimCook)\
**Post date:** [October 8, 2016, 9:47am UTC](https://forums.developer.nvidia.com/t/cmake-cannot-find-lopencv-dep-cudart/45392/3 "2016-10-08T09:47:03Z")

</div>

Maybe some dependent lib wasn’t installed.  
Try:

```auto
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:

```auto
cmake -D WITH_CUDA=ON \
    -D ENABLE_FAST_MATH=1 \
    -D CUDA_FAST_MATH=1 \
    -D INSTALL_C_EXAMPLES=OFF \
    -D WITH_CUBLAS=1 \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules ~/opencv \
    -D BUILD_EXAMPLES=ON \
    -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local ..

sudo make -j4
sudo make install

```

---

<div class="post-metadata">

**Author:** ![TimCook](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@TimCook](https://forums.developer.nvidia.com/u/TimCook)\
**Post date:** [October 8, 2016, 11:07am UTC](https://forums.developer.nvidia.com/t/cmake-cannot-find-lopencv-dep-cudart/45392/4 "2016-10-08T11:07:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Lucas\_7](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Lucas\_7](https://forums.developer.nvidia.com/u/Lucas_7)\
**Post date:** [October 8, 2016, 6:02pm UTC](https://forums.developer.nvidia.com/t/cmake-cannot-find-lopencv-dep-cudart/45392/5 "2016-10-08T18:02:43Z")

</div>

In which directory should I run “cmake -D WITH\_CUDA[…]” ?

---

<div class="post-metadata">

**Author:** ![Gary\_4001](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/gary_4001/32/12639_2.png) [@Gary\_4001](https://forums.developer.nvidia.com/u/Gary_4001)\
**Post date:** [October 11, 2016, 5:24pm UTC](https://forums.developer.nvidia.com/t/cmake-cannot-find-lopencv-dep-cudart/45392/6 "2016-10-11T17:24:26Z")

</div>

> [@](#):
>
> Maybe some dependent lib wasn’t installed.  
> Try:
> 
> ```auto
> 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:
> 
> ```auto
> cmake -D WITH_CUDA=ON \
> -D ENABLE_FAST_MATH=1 \
> -D CUDA_FAST_MATH=1 \
> -D INSTALL_C_EXAMPLES=OFF \
> -D WITH_CUBLAS=1 \
> -D INSTALL_PYTHON_EXAMPLES=ON \
> -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules ~/opencv \
> -D BUILD_EXAMPLES=ON \
> -D CMAKE_BUILD_TYPE=RELEASE \
> -D CMAKE_INSTALL_PREFIX=/usr/local ..
> 
> sudo make -j4
> sudo make install
> 
> ```

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?

---

<div class="post-metadata">

**Author:** ![jachen](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/jachen/32/14043_2.png) [@jachen](https://forums.developer.nvidia.com/u/jachen)\
**Post date:** [October 14, 2016, 3:00am UTC](https://forums.developer.nvidia.com/t/cmake-cannot-find-lopencv-dep-cudart/45392/7 "2016-10-14T03:00:37Z")

</div>

Hello,  
Would you please provide the detailed log/program you wanna compile?  
I do not know which program need lib opencv\_dep\_cudart.

br  
Chenjian

---

<div class="post-metadata">

**Author:** ![raak](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@raak](https://forums.developer.nvidia.com/u/raak)\
**Post date:** [October 14, 2016, 6:42am UTC](https://forums.developer.nvidia.com/t/cmake-cannot-find-lopencv-dep-cudart/45392/8 "2016-10-14T06:42:37Z")

</div>

Same issue here

```auto
/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

```

---

<div class="post-metadata">

**Author:** ![raak](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@raak](https://forums.developer.nvidia.com/u/raak)\
**Post date:** [October 14, 2016, 7:08am UTC](https://forums.developer.nvidia.com/t/cmake-cannot-find-lopencv-dep-cudart/45392/9 "2016-10-14T07:08:07Z")

</div>

This is working fine, before i flashed.

```auto
cmake_minimum_required(VERSION 2.8)

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

find_package(OpenCV REQUIRED)
find_package(CUDA)

set(
	CUDA_NVCC_FLAGS
	${CUDA_NVCC_FLAGS};
    -O3 -gencode arch=compute_53,code=sm_53
)

include_directories("/usr/local/cuda-8.0/include")
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})

```

```auto

```

---

<div class="post-metadata">

**Author:** ![raak](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@raak](https://forums.developer.nvidia.com/u/raak)\
**Post date:** [October 14, 2016, 8:04am UTC](https://forums.developer.nvidia.com/t/cmake-cannot-find-lopencv-dep-cudart/45392/10 "2016-10-14T08:04:15Z")

</div>

This seems working for me

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

```auto
set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)

```

---

<div class="post-metadata">

**Author:** ![Gary\_4001](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/gary_4001/32/12639_2.png) [@Gary\_4001](https://forums.developer.nvidia.com/u/Gary_4001)\
**Post date:** [October 20, 2016, 8:55pm UTC](https://forums.developer.nvidia.com/t/cmake-cannot-find-lopencv-dep-cudart/45392/11 "2016-10-20T20:55:24Z")

</div>

> [@](#):
>
> This seems working for me
> 
> ln -s /usr/local/cuda8-0/lib64/libcudart.so /usr/local/lib/  
> ln -s /usr/local/cuda8-0/lib64/libcudart.a /usr/local/lib/
> 
> ```auto
> set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)
> 
> ```

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

---

<div class="post-metadata">

**Author:** ![Eyshika](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Eyshika](https://forums.developer.nvidia.com/u/Eyshika)\
**Post date:** [July 16, 2017, 5:04pm UTC](https://forums.developer.nvidia.com/t/cmake-cannot-find-lopencv-dep-cudart/45392/12 "2017-07-16T17:04:50Z")

</div>

Hello,  
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 ?

---

<div class="post-metadata">

**Author:** ![snarky](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/snarky/32/10446_2.png) [@snarky](https://forums.developer.nvidia.com/u/snarky)\
**Post date:** [July 27, 2017, 5:36am UTC](https://forums.developer.nvidia.com/t/cmake-cannot-find-lopencv-dep-cudart/45392/13 "2017-07-27T05:36:06Z")

</div>

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 libcudart.so; 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:

```auto
--- /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}")
     endif()
   endforeach()
+
+ # 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/libcudart.so)
+
 endif()

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

```

---

<div class="post-metadata">

**Author:** ![wangyz](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@wangyz](https://forums.developer.nvidia.com/u/wangyz)\
**Post date:** [July 27, 2017, 11:28am UTC](https://forums.developer.nvidia.com/t/cmake-cannot-find-lopencv-dep-cudart/45392/14 "2017-07-27T11:28:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Eyshika](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Eyshika](https://forums.developer.nvidia.com/u/Eyshika)\
**Post date:** [August 1, 2017, 12:29am UTC](https://forums.developer.nvidia.com/t/cmake-cannot-find-lopencv-dep-cudart/45392/15 "2017-08-01T00:29:07Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![AastaLLL](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/aastalll/32/14043_2.png) [@AastaLLL](https://forums.developer.nvidia.com/u/AastaLLL)\
**Post date:** [August 3, 2017, 9:20am UTC](https://forums.developer.nvidia.com/t/cmake-cannot-find-lopencv-dep-cudart/45392/16 "2017-08-03T09:20:02Z")

</div>

Hi Eyshika,

Do you want to use OpenCV or OpenVX?

---

<div class="post-metadata">

**Author:** ![Eyshika](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Eyshika](https://forums.developer.nvidia.com/u/Eyshika)\
**Post date:** [August 12, 2017, 12:17am UTC](https://forums.developer.nvidia.com/t/cmake-cannot-find-lopencv-dep-cudart/45392/17 "2017-08-12T00:17:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![AastaLLL](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/aastalll/32/14043_2.png) [@AastaLLL](https://forums.developer.nvidia.com/u/AastaLLL)\
**Post date:** [August 14, 2017, 2:50am UTC](https://forums.developer.nvidia.com/t/cmake-cannot-find-lopencv-dep-cudart/45392/18 "2017-08-14T02:50:30Z")

</div>

Hi,

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.

> **[Vision Programming Interface (VPI)](https://developer.nvidia.com/embedded/vpi)**
>
> Helps developers to solve challenges when working with Jetson embedded devices.

---

<div class="post-metadata">

**Author:** ![Eyshika](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Eyshika](https://forums.developer.nvidia.com/u/Eyshika)\
**Post date:** [August 23, 2017, 9:28pm UTC](https://forums.developer.nvidia.com/t/cmake-cannot-find-lopencv-dep-cudart/45392/19 "2017-08-23T21:28:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![AastaLLL](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/aastalll/32/14043_2.png) [@AastaLLL](https://forums.developer.nvidia.com/u/AastaLLL)\
**Post date:** [August 24, 2017, 2:08am UTC](https://forums.developer.nvidia.com/t/cmake-cannot-find-lopencv-dep-cudart/45392/20 "2017-08-24T02:08:00Z")

</div>

Hi,

Please share OpenVX sample and error message for us debugging.  
One possible reason is not correctly linking to VisionWorks libraries.  
Please check this topic:  
[https://devtalk.nvidia.com/default/topic/1016273/jetson-tx2/visionworks-linking-problem/](https://devtalk.nvidia.com/default/topic/1016273/jetson-tx2/visionworks-linking-problem/)

[Next page](https://forums.developer.nvidia.com/t/cmake-cannot-find-lopencv-dep-cudart/45392.md?page=2)
