Jetpack 2.3 error compiling hello world (cannot find -lopencv_dep_cudart)

I did a fresh flash of Jetpack 2.3 today and am following the video tutorials to familiarize myself with the TX1. This OpenCV hello world application doesn’t compile for me due to missing libraries. Does the tutorial not work on the most recent version of jetpack or am I doing something wrong?

Here’s the code:


#include <opencv2/highgui/highgui.hpp>

int main() {
	cv::Mat img(512, 512, CV_8UC3, cv::Scalar(0));

		"Hello OpenCV on Jetson!",
		cv::Point(10, img.rows / 2),
		CV_RGB(118, 185, 0),
	cv::imshow("Hello", img);


cmake_minimum_required(VERSION 2.8)


find_package(OpenCV REQUIRED)


add_executable(cv_hello hello.cpp)

target_link_libraries(cv_hello ${OpenCV_LIBS})
ubuntu@tegra-ubuntu:~/Desktop/hello_world/build$ cmake ..
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found CUDA: /usr/local/cuda-8.0 (found suitable exact version "8.0")
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ubuntu/Desktop/hello_world/build
ubuntu@tegra-ubuntu:~/Desktop/hello_world/build$ make
Scanning dependencies of target cv_hello
[ 50%] Building CXX object CMakeFiles/cv_hello.dir/hello.cpp.o
[100%] Linking CXX executable cv_hello
/usr/bin/ld: cannot find -lopencv_dep_cudart
collect2: error: ld returned 1 exit status
CMakeFiles/cv_hello.dir/build.make:121: recipe for target 'cv_hello' failed
make[2]: *** [cv_hello] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/cv_hello.dir/all' failed
make[1]: *** [CMakeFiles/cv_hello.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

I see on that tutorial the sample was built on a Jetson TK1, not the TX1. I don’t know what JetPack provides which could be used for that tutorial, but you would definitely have to install supporting libraries first…the TX1 version would be different from the TK1 version, but if that supporting infrastructure is in place, then it should in theory succeed.

I couldn’t tell you what needs to be installed, but this error indicates a library under CUDA was not found:

/usr/bin/ld: cannot find -lopencv_dep_cudart

…perhaps this differs because of the CUDA 8 version, but the missing link library is definitely from one of the CUDA versions. It wouldn’t be unusual that a major version increment from the JTK1’s CUDA 6.5 to JTX1’s CUDA 8.0 changes what libraries and interfaces are available.

I’m actually facing the same problem, even though the tutorial says it should work for both the TK1 and the TX1. I’m using the TX1. If anybody can help with a simple “Hello-World” on TX1, using opencv and oher.

You probably need to post specific build commands and errors. Do make sure that you have any prerequisite libraries installed first.

I’ve just installed JetPack-2.3 on a Jetson TX1 and tried to compile hello.cpp against the stock OpenCV4Tegra (2.4.13). It worked OK.

$ g++ -o hello hello.cpp -lopencv_core -lopencv_highgui
$ ./hello

I stumbled across this fix :


Your guess is as good as mine as to what this does, but it seemed to work.