Error Compiling Application Opencv

I established Opencv with the following links;

1- http://docs.opencv.org/3.2.0/d6/d15/tutorial_building_tegra_cuda.html ve

2 -http://elinux.org/Jetson/Installing_OpenCV

Later;
1- https://www.youtube.com/watch?v=gvmP0WRVUxI

2- http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_gcc_cmake/linux_gcc_cmake.html

I wanted to try the examples in these links.

When I try to compile the sample application, I get an error like this:

After you write the “make” command;

[ 50%] Linking CXX executable DisplayImage
/usr/bin/ld: cannot find -lopencv_dep_cudart
collect2: error: ld returned 1 exit status
CMakeFiles/DisplayImage.dir/build.make:117: recipe for target ‘DisplayImage’ failed
make[2]: *** [DisplayImage] Error 1
CMakeFiles/Makefile2:67: recipe for target ‘CMakeFiles/DisplayImage.dir/all’ failed
make[1]: *** [CMakeFiles/DisplayImage.dir/all] Error 2
Makefile:83: recipe for target ‘all’ failed
make: *** [all] Error 2

How can I solve this problem?
Thank you…

/usr/bin/ld: cannot find -lopencv_dep_cudart

Looks for linking your sample executable, the linker misses libopencv_dep_cudart.so.

It seems you’ve built OpenCv3.2.0 and you are trying to compile samples for OpenCv2.4.

I have no TX1 with me for checking, but the libraries and namespaces changed from opencv2 to opencv3.

What is your opencv include path ?

If you can find where is libopencv_dep_cudart.so on your system, just type:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:path_to_your_opencvlib_directory

make

The environnement variable LD_LIBRARY_PATH holds the list of non standard paths for dynamic libraries. You just have to set it once.
Note that for running the executable, this also needs to be defined.

Hi,

Please add following flag in CmakeList.txt

set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)

Read more at https://github.com/opencv/opencv/issues/6542

I faced the same issue when I was trying out the tutorials. I am using the inbuilt version of OpenCV (2.4). The following steps solved the issue for me:

Step 1: Put the code and the CMakeLists.txt file in a folder (code is same as in the tutorials). The executable is cv_hello. Now open the terminal from the folder and execute the following commands.

Step 2:

cmake -DCUDA_USE_STATIC_CUDA_RUNTIME=OFF

Step 3:

make

Step 4:

./cv_hello