/usr/bin/ld: cannot find -lopencv_dep_cudart

Hi all,

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!
Marc

Seems like setting -DCUDA_USE_STATIC_CUDA_RUNTIME=false worked in some cases. What exactly is this?

Some help on this issue would be great. I’m seeing the same thing with the latest L4T image.

var name is CUDAUSESTATIC_CUDA_RUNTIME not CUDA_STATIC_CUDA_RUNTIME

Downgraded to Jetpack 2.1 and seems to work. Sucks to have to revert to an old image. A fix would be great.

Hi,

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)

Thanks and really sorry about the inconvenience.

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!

any help or fix will be welcome

Hi,

This is a known issue we are working on.

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.

You can’t compile application even with ‘set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)’?

I can’t compile the application even with CUDA_USE_STATIC_CUDA_RUNTIME OFF

Hi,

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.

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)

find_package(ZED 2.0 REQUIRED)

##For Jetson, OpenCV4Tegra is based on OpenCV2.4
exec_program(uname ARGS -p OUTPUT_VARIABLE CMAKE_SYSTEM_NAME2)
if ( CMAKE_SYSTEM_NAME2 MATCHES “aarch64” ) # Jetson TX1
SET(OCV_VERSION “2.4”)
SET(CUDA_VERSION “8.0”)
SET(CUDA_USE_STATIC_CUDA_RUNTIME OFF)
else() # Ubuntu Desktop
SET(OCV_VERSION “3.1”)
SET(CUDA_VERSION “8.0”)
endif()
find_package(OpenCV {OCV_VERSION} COMPONENTS core highgui imgproc REQUIRED) find_package(CUDA {CUDA_VERSION} REQUIRED)

find_package(PCL REQUIRED)

find_package(catkin REQUIRED COMPONENTS
image_transport
roscpp
rosconsole
sensor_msgs
dynamic_reconfigure
tf2_ros
pcl_conversions
nodelet
)

generate_dynamic_reconfigure_options(
cfg/Zed.cfg
)

catkin_package(
CATKIN_DEPENDS
roscpp
rosconsole
sensor_msgs
opencv
image_transport
dynamic_reconfigure
tf2_ros
pcl_conversions
)

###############################################################################

INCLUDES

Hi,

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)
........

sorry but this fails to work too

Scanning dependencies of target zed_wrapper_gencfg
Scanning dependencies of target sweep_node
[ 14%] Built target zed_wrapper_gencfg
Scanning dependencies of target ZEDWrapper
[ 28%] Building CXX object sweep-ros/CMakeFiles/sweep_node.dir/src/node.cpp.o
[ 42%] Building CXX object zed-ros-wrapper-master/CMakeFiles/ZEDWrapper.dir/src/zed_wrapper_nodelet.cpp.o
[ 57%] Linking CXX executable /home/ubuntu/catkin_ws/devel/lib/sweep_ros/sweep_node
[ 57%] Built target sweep_node
[ 71%] Linking CXX shared library /home/ubuntu/catkin_ws/devel/lib/libZEDWrapper.so
/usr/bin/ld: cannot find -lopencv_dep_cudart
collect2: error: ld returned 1 exit status
zed-ros-wrapper-master/CMakeFiles/ZEDWrapper.dir/build.make:444: recipe for target ‘/home/ubuntu/catkin_ws/devel/lib/libZEDWrapper.so’ failed
make[2]: *** [/home/ubuntu/catkin_ws/devel/lib/libZEDWrapper.so] Error 1
CMakeFiles/Makefile2:1447: recipe for target ‘zed-ros-wrapper-master/CMakeFiles/ZEDWrapper.dir/all’ failed
make[1]: *** [zed-ros-wrapper-master/CMakeFiles/ZEDWrapper.dir/all] Error 2
Makefile:138: recipe for target ‘all’ failed
make: *** [all] Error 2
Invoking “make -j4 -l4” failed

Hi,

Please clean build the project.
If still met error, please share your environment, is JetPack3.0 with cuda-toolkit and opencv4Tegra installed?

By cleaning the build project has no effect, I’m still unable to compile

I’m using Jetpack 3.0 with cuda-tollkit and the openCV4 for Tegra, installed as default

Hi HenryAcev,

Could you try to add this param when running cmake instead of adding in CMakeLists?

cmake -DCUDA_USE_STATIC_CUDA_RUNTIME=OFF

:)

It seems to work as workaround

Thank you

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: https://github.com/rgiduthuri/openvx_tutorial
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.

Hi Eyshika,

Could you paste the error log here? I don’t quite get the meaning of “it has a realtime video.so”

The error “opencv_dep_cudart not found” and its solution “set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)” is related only to cudart.