NVCC Linker Error while compile a project with OpenCV

Hello.

I’m trying to use OpenCV4Tegra.

I’ve added information in nsight as below.

Add include path “/usr/include” in Properties/Build/Settings/Tool settings/NVCC Compiler/includes.
And Add library path “/usr/lib” and libraries “libopencv_core.so libopencv_highgui.so etc” in Properties/Build/Settings/Tool settings/NVCC Linker/Libraries.
And Add LD_LIBRARY_PATH "LD_LIBRARY_PATH /usr/lib/"in Properties/Build/Environment.

But NVCC Liner showed error message like this.

/usr/bin/ld: cannot find -llibopencv_core.so
/usr/bin/ld: cannot find -llibopencv_highgui.so

I’m certain that .so files are in “/usr/lib”.

Could someone tell me how to solve this issue?

Thanks.

Hi,

Could you change opencv library link to /usr/local/lib/ and try it again?

Hello, AastaLL.

Thank you for your quick response.

I tried your suggestion, but failed bacause, I couldn’t find any libopencv*.so files in /usr/local/lib/. Only pathon2.7, pathon3.5 folder are there.

Thanks.

Hello KADU06,

If you’re compiling with cmake, you have to cmake in the build directory by doing

sudo cmake … -DCUDA_USE_STATIC_CUDA_RUNTIME=false

But one extra thing I noticed is that if I try to ‘make’ afterwards it won’t work unless I do the cmake command twice.

Hello Void12987.
Thank you for your reply.

I tried your idea in nsight on HOST-PC as below.
property/Build/Settings/NVCC COmpiler/symbols/Defined symbols(-D) CUDA_USE_STATIC_RUNTIME=false

I had to tell more info. that OpenCV isn’t installed on HOST-PC, but OpenCV4Tegra is installed on TegraX1,
and the main() function doesn’t include GPU function at all.

I’ll attatch nsight’s messages here.

Can you see any problems?
I’m not sure TegraX1 recognize “/usr/lib” path I’ve set despite I’ve set it on HOST-PC’s nsight.

################################################
09:52:16 **** Build of configuration Release for project OpenCVSample ****
make all -C /home/ubuntu/cuda-workspace/Release
make: Entering directory ‘/home/ubuntu/cuda-workspace/Release’
Building file: …/SampleOpenCV.cpp
Invoking: NVCC Compiler
/usr/local/cuda-8.0/bin/nvcc -DCUDA_USE_STASTIC_CUDA_RUNTIME=false -I/usr/include -O3 -v -ccbin aarch64-linux-gnu-g++ -gencode arch=compute_20,code=sm_20 -m64 -odir “.” -M -o “SampleOpenCV.d” “…/SampleOpenCV.cpp”
nvcc warning : The ‘compute_20’, ‘sm_20’, and ‘sm_21’ architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
# _SPACE_= # CUDART=cudart
# _HERE_=/usr/local/cuda-8.0/bin # THERE=/usr/local/cuda-8.0/bin
# _TARGET_SIZE_= # TARGET_DIR=
# _TARGET_DIR_=targets/aarch64-linux # TOP=/usr/local/cuda-8.0/bin/…
# NVVMIR_LIBRARY_DIR=/usr/local/cuda-8.0/bin/../nvvm/libdevice # LD_LIBRARY_PATH=/usr/local/cuda-8.0/bin/…/lib:
# PATH=/usr/local/cuda-8.0/bin/../open64/bin:/usr/local/cuda-8.0/bin/../nvvm/bin:/usr/local/cuda-8.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin # INCLUDES="-I/usr/local/cuda-8.0/bin/…/targets/aarch64-linux/include"
# LIBRARIES= "-L/usr/local/cuda-8.0/bin/../targets/aarch64-linux/lib/stubs" "-L/usr/local/cuda-8.0/bin/../targets/aarch64-linux/lib" # CUDAFE_FLAGS=
# PTXAS_FLAGS= # aarch64-linux-gnu-g++ -E -x c++ -D__NVCC__ -O3 -I"/usr/include" “-I/usr/local/cuda-8.0/bin/…/targets/aarch64-linux/include” -D"CUDACC_VER=80033" -D"CUDACC_VER_BUILD=33" -D"CUDACC_VER_MINOR=0" -D"CUDACC_VER_MAJOR=8" -D"CUDA_USE_STASTIC_CUDA_RUNTIME=false" “…/SampleOpenCV.cpp” > “/tmp/tmpxft_00000fa7_00000000-2_SampleOpenCV.ii”
# -- Filter Dependencies -- > SampleOpenCV.d /usr/local/cuda-8.0/bin/nvcc -DCUDA_USE_STASTIC_CUDA_RUNTIME=false -I/usr/include -O3 -v --compile -m64 -ccbin aarch64-linux-gnu-g++ -x c++ -o "SampleOpenCV.o" "../SampleOpenCV.cpp" nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning). # SPACE=
# _CUDART_=cudart # HERE=/usr/local/cuda-8.0/bin
# _THERE_=/usr/local/cuda-8.0/bin # TARGET_SIZE=
# _TARGET_DIR_= # TARGET_DIR=targets/aarch64-linux
# TOP=/usr/local/cuda-8.0/bin/.. # NVVMIR_LIBRARY_DIR=/usr/local/cuda-8.0/bin/…/nvvm/libdevice
# LD_LIBRARY_PATH=/usr/local/cuda-8.0/bin/../lib: # PATH=/usr/local/cuda-8.0/bin/…/open64/bin:/usr/local/cuda-8.0/bin/…/nvvm/bin:/usr/local/cuda-8.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
# INCLUDES="-I/usr/local/cuda-8.0/bin/../targets/aarch64-linux/include" # LIBRARIES= “-L/usr/local/cuda-8.0/bin/…/targets/aarch64-linux/lib/stubs” “-L/usr/local/cuda-8.0/bin/…/targets/aarch64-linux/lib”
# CUDAFE_FLAGS= # PTXAS_FLAGS=
#$ aarch64-linux-gnu-g++ -c -x c++ -D__NVCC__ -O3 -I"/usr/include" “-I/usr/local/cuda-8.0/bin/…/targets/aarch64-linux/include” -D"CUDACC_VER=80033" -D"CUDACC_VER_BUILD=33" -D"CUDACC_VER_MINOR=0" -D"CUDACC_VER_MAJOR=8" -D"CUDA_USE_STASTIC_CUDA_RUNTIME=false" -o “SampleOpenCV.o” “…/SampleOpenCV.cpp”
Finished building: …/SampleOpenCV.cpp

Building target: OpenCVSample
Invoking: NVCC Linker
/usr/local/cuda-8.0/bin/nvcc --cudart static -L/usr/lib --relocatable-device-code=false -gencode arch=compute_20,code=compute_20 -gencode arch=compute_20,code=sm_20 -m64 -ccbin aarch64-linux-gnu-g++ -link -o “OpenCVSample” ./SampleOpenCV.o -llibopencv_core.so -llibopencv_gpu.so -llibopencv_highgui.so
nvcc warning : The ‘compute_20’, ‘sm_20’, and ‘sm_21’ architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
/usr/bin/ld: cannot find -llibopencv_core.so
/usr/bin/ld: cannot find -llibopencv_gpu.so
/usr/bin/ld: cannot find -llibopencv_highgui.so
collect2: error: ld returned 1 exit status
makefile:58: recipe for target ‘OpenCVSample’ failed
make: *** [OpenCVSample] Error 1
make: Leaving directory ‘/home/ubuntu/cuda-workspace/Release’

Shell Completed (exit code = 2)

09:52:18 Build Finished (took 2s.660ms)
########################################################

Thanks.

Hello everyone.

I’ve got the solution from eclipse’s forum.

I made a basic mistake to specify library files.

I should’ve specifed the lib file name “opencv_core” instead of “libopencv_core.so”.

Thank you.