C++ Tricks

Building

error adding symbols: DSO missing from command line

if your binutils>=2.22, linker cannot found the symbol that you don’t specified in command line. (Even if this symbol is linked by another lib)

OR

you can fix this by adding --allow-shlib-undefined

/usr/bin/ld: cannot find -lopencv_dep_cudart

When I compile OpenCV 2.4.13.5, build error for:
/usr/bin/ld: cannot find -lopencv_dep_cudart

Some forum and issue said they have solution by adding these options -DCUDA_USE_STATIC_CUDA_RUNTIME=OFF and -DCUDA_USE_STATIC_CUDA_RUNTIME=false but not work at all.

Way 1

I found a patch on Nvidia user forum, it work!

+++ /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()

Way 2

An alternative way is amend /usr/share/cmake-3.5/Modules/FindCUDA.cmake file.


Coding

IDE

Clion

See this page

Eclipse

See this page