Compile Error: cannot find -lopencv_contrib & -lopencv_gpu

I compile openpose in my jetson-nano. I got an error.

NOTE: This script assumes that just flashed JetPack 3.3 : Ubuntu 16, CUDA 9, cuDNN 7 and OpenCV are already installed on your machine. Otherwise, it might fail.
------------------------- Compiling OpenPose -------------------------
CXX/LD -o .build_release/examples/calibration/calibration.bin
CXX/LD -o .build_release/examples/openpose/openpose.bin
CXX/LD -o .build_release/examples/tutorial_add_module/1_custom_post_processing.bin
CXX/LD -o .build_release/examples/tutorial_api_cpp/04_keypoints_from_images.bin
/usr/bin/ld: cannot find -lopencv_contrib
/usr/bin/ld: cannot find -lopencv_gpu
collect2: error: ld returned 1 exit status
Makefile:492: recipe for target '.build_release/examples/calibration/calibration.bin' failed
make: *** [.build_release/examples/calibration/calibration.bin] Error 1
make: *** Waiting for unfinished jobs....
/usr/bin/ld: cannot find -lopencv_contrib
/usr/bin/ld: cannot find -lopencv_gpu
collect2: error: ld returned 1 exit status
Makefile:492: recipe for target '.build_release/examples/openpose/openpose.bin' failed
make: *** [.build_release/examples/openpose/openpose.bin] Error 1
/usr/bin/ld: cannot find -lopencv_contrib
/usr/bin/ld: cannot find -lopencv_gpu
/usr/bin/ld: cannot find -lopencv_contrib
/usr/bin/ld: cannot find -lopencv_gpu
collect2: error: ld returned 1 exit status
Makefile:492: recipe for target '.build_release/examples/tutorial_api_cpp/04_keypoints_from_images.bin' failed
make: *** [.build_release/examples/tutorial_api_cpp/04_keypoints_from_images.bin] Error 1
collect2: error: ld returned 1 exit status
Makefile:492: recipe for target '.build_release/examples/tutorial_add_module/1_custom_post_processing.bin' failed
make: *** [.build_release/examples/tutorial_add_module/1_custom_post_processing.bin] Error 1

------------------------- -------------------------
Errors detected. Exiting script. The software might have not been successfully installed.
------------------------- -------------------------

When edit Makfile , using “OPENCV_VERSION := 3” ,I got an other error.

------------------------- Installing OpenPose -------------------------
NOTE: This script assumes that just flashed JetPack 3.3 : Ubuntu 16, CUDA 9, cuDNN 7 and OpenCV are already installed on your machine. Otherwise, it might fail.
------------------------- Compiling OpenPose -------------------------
CXX/LD -o .build_release/examples/calibration/calibration.bin
CXX/LD -o .build_release/examples/openpose/openpose.bin
CXX/LD -o .build_release/examples/tutorial_add_module/1_custom_post_processing.bin
CXX/LD -o .build_release/examples/tutorial_api_cpp/04_keypoints_from_images.bin
/usr/bin/ld: .build_release/examples/calibration/calibration.o: undefined reference to symbol '_ZN2cv6String10deallocateEv'
/usr/lib/libopencv_core.so.3.3: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:492: recipe for target '.build_release/examples/calibration/calibration.bin' failed
make: *** [.build_release/examples/calibration/calibration.bin] Error 1
make: *** Waiting for unfinished jobs....
/usr/bin/ld: .build_release/examples/openpose/openpose.o: undefined reference to symbol '_ZN2cv6String10deallocateEv'
/usr/lib/libopencv_core.so.3.3: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:492: recipe for target '.build_release/examples/openpose/openpose.bin' failed
make: *** [.build_release/examples/openpose/openpose.bin] Error 1
/usr/bin/ld: warning: libopencv_core.so.3.3, needed by ./3rdparty/caffe/distribute/lib/libcaffe.so, may conflict with libopencv_core.so.4.0
/usr/bin/ld: .build_release/examples/tutorial_add_module/1_custom_post_processing.o: undefined reference to symbol '_ZN2cv6String10deallocateEv'
/usr/lib/libopencv_core.so.3.3: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:492: recipe for target '.build_release/examples/tutorial_add_module/1_custom_post_processing.bin' failed
make: *** [.build_release/examples/tutorial_add_module/1_custom_post_processing.bin] Error 1
/usr/bin/ld: warning: libopencv_core.so.3.3, needed by ./3rdparty/caffe/distribute/lib/libcaffe.so, may conflict with libopencv_core.so.4.0
/usr/bin/ld: .build_release/examples/tutorial_api_cpp/04_keypoints_from_images.o: undefined reference to symbol '_ZN2cv6String10deallocateEv'
/usr/lib/libopencv_core.so.3.3: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:492: recipe for target '.build_release/examples/tutorial_api_cpp/04_keypoints_from_images.bin' failed
make: *** [.build_release/examples/tutorial_api_cpp/04_keypoints_from_images.bin] Error 1

------------------------- -------------------------
Errors detected. Exiting script. The software might have not been successfully installed.
------------------------- -------------------------
jetson-nano:~/nas/openpose$ jetson_release
 - NVIDIA Jetson NANO/TX1
   * Jetpack 4.2 [L4T 32.1.0]
   * CUDA GPU architecture 5.3
 - Libraries:
   * CUDA 10.0.166
   * cuDNN 7.3.1.28-1+cuda10.0
   * TensorRT 5.0.6.3-1+cuda10.0
   * Visionworks 1.6.0.500n
   * OpenCV 4.0.0 compiled CUDA: YES
 - Jetson Performance: inactive
 - Jetson Easy v1.5.0

Do you have an idea how to fix this? :)

Hi,

It looks like the script is only verified with JetPack3.3/ It may not work on the v4.2.

NOTE: This script assumes that just flashed JetPack 3.3 : Ubuntu 16, CUDA 9, cuDNN 7 and OpenCV are already installed on your machine. Otherwise, it might fail.

Anyway, to fix the opencv library missing, you can build it from source.
We have script can do this automatically:
https://github.com/AastaNV/JEP/blob/master/script/install_opencv4.0.0_Nano.sh

Thanks.

Hi,

I also encontered this issue.
I work on Jetson AGX Xavier, but the script install_opnecv4.3.0_Jetson.sh from AastaNV’s github didn’t include the gpu module. I added it but don’t know how to compile the -lopencv_gpu librarie

Could you help me ?

Thank you

Hi Jer.vincent,

Please open a new topic for your issue. Thanks