Recently decided to upgrade one of our TX1s to the newest L4T. This moved us forward to 16.04 and ROS Kinetic.
Now, however, any program that links to OpenCV throws the error:
/usr/bin/ld: cannot find -lopencv_dep_cudart
when we try to compile it. Currently, we have only OpenCV4Tegra installed (didn’t mess with OpenCV at all) since we want to use NVIDIA’s optimizations.
We’ve already tried to add -DCUDA_STATIC_CUDA_RUNTIME=OFF as well as do a set(CUDA_STATIC_CUDA_RUNTIME OFF) in the CMakeLists.txt
For some packages this worked, but for some it just won’t compile and continuously throws the error. What changed with the newest L4T version that OpenCV is causing trouble again? I thought this was fixed a while ago… Does anyone have any tips for getting this to work? What exactly is this -lopencv_dep_cudart ?
Thanks for your question.
This is a known issue and can be fixed by adding ‘set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)’ to CmakeLists.txt.
Root cause is:
In /usr/share/OpenCV/OpenCVModules-release.cmake, it require opencv_dep_cudart library.
However, we don’t have libopencv_dep_cudart.a but libcudart_static.a.
Turn-off CUDA_USE_STATIC_CUDA_RUNTIME can skip this issue.
Older cmake(2.8), which default set CUDA_USE_STATIC_CUDA_RUNTIME off, also can avoid this issue.
That’s why it works well with JetPack2.1.
We care about this issue.
Please let us know if your function can’t work well with ‘set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)’.
(It will be perfect if you can attach a sample code for us reproducing the error)
I had test it, and by adding set(CUDA_USE_STATIC_CUDA_RUNTIME OFF) on the usr/share/OpenCV/OpenCVModules-release.cmake will not make any difference at all
also I had added/tested on the CMakelists.txt file on the ZED ROS wrapper and doesn’t help either
I’m really surprised that this issue stills around after six months!
Just want to confirm:
You can’t compile application even with ‘set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)’?
Please make sure you set this property before include CUDA library.
This issue is from standard opencv source and we try to find a better way to fix or help this problem.
Usually, it can be fixed with ‘set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)’.
If you still met error when compiling, could you share your CMakeLists for us debugging?
Thanks.
Could you try to modify your CMakeList file to this:
<b>SET(CUDA_USE_STATIC_CUDA_RUNTIME OFF)</b>
cmake_minimum_required(VERSION 2.8.7)
project(zed_wrapper)
# if CMAKE_BUILD_TYPE is not specified, take 'Release' as default
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release)
ENDIF(NOT CMAKE_BUILD_TYPE)
........
Occasionally, I will get an the error “/usr/bin/ld: cannot find -lopencv_dep_cudart
collect2: error: ld returned 1 exit status”
As I go through some of the sample NVIDIA videos, I copy my CMakeLists.txt file from directory (project) to directory. For some reason, sometimes I have to edit the CMakeLists.txt file and delete the line:
set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)
and re-enter the whole line again. That seems to allow my project to compile and run.
Hi Aasta,
I tried your method when i started learning opencv on jetson from videos and created a helo-world program. It worked successfully, but here is a catch. when I cloned openvx_tutorials from here: GitHub - rgiduthuri/openvx_tutorial: Khronos OpenVX Tutorial Material
and tried to build it in qtcreator using your same command in cmakelist, it couldn’t run because it has a realtime video. so, i guess this fix is still not working with videos. and it worked with opencv hello-world because it was just an image.
P.S. i am using Jetson TX1, opencv4tegra, visionworks and cuda8.0
It would be great if you can come up with forever fix.