1

I am trying to add some opencv code to the detectnet-console and detectnet-camrea cpp files in the jetson-inference tutorial. BUT when i build the model it shows me the following error

[ 74%] Linking CXX executable ../aarch64/bin/detectnet-console
CMakeFiles/detectnet-console.dir/detectnet-console.cpp.o: In function cv::String::String(char const*)': detectnet-console.cpp:(.text._ZN2cv6StringC2EPKc[_ZN2cv6StringC5EPKc]+0x4c): undefined reference to cv::String::allocate(unsigned long)'
CMakeFiles/detectnet-console.dir/detectnet-console.cpp.o: In function cv::String::~String()': detectnet-console.cpp:(.text._ZN2cv6StringD2Ev[_ZN2cv6StringD5Ev]+0x10): undefined reference to cv::String::deallocate()'
CMakeFiles/detectnet-console.dir/detectnet-console.cpp.o: In function cv::Mat::Mat(int, int, int, void*, unsigned long)': detectnet-console.cpp:(.text._ZN2cv3MatC2EiiiPvm[_ZN2cv3MatC5EiiiPvm]+0x144): undefined reference to cv::error(int, cv::String const&, char const*, char const*, int)'
detectnet-console.cpp:(.text._ZN2cv3MatC2EiiiPvm[_ZN2cv3MatC5EiiiPvm]+0x258): undefined reference to cv::error(int, cv::String const&, char const*, char const*, int)' CMakeFiles/detectnet-console.dir/detectnet-console.cpp.o: In function cv::Mat::~Mat()':
detectnet-console.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x34): undefined reference to cv::fastFree(void*)' CMakeFiles/detectnet-console.dir/detectnet-console.cpp.o: In function cv::Mat::release()':
detectnet-console.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x58): undefined reference to `cv::Mat::deallocate()'
collect2: error: ld returned 1 exit status
detectnet-console/CMakeFiles/detectnet-console.dir/build.make:102: recipe for target 'aarch64/bin/detectnet-console' failed
make[2]: *** [aarch64/bin/detectnet-console] Error 1
CMakeFiles/Makefile2:235: recipe for target 'detectnet-console/CMakeFiles/detectnet-console.dir/all' failed
make[1]: *** [detectnet-console/CMakeFiles/detectnet-console.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2 

which i have searched for a solution and the problem is when compiling i need to add this

pkg-config opencv --cflags --libs

but i dont know which part of the cmake i should add it to .

any help in this matter

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
MadLord
  • 21
  • 3
  • There are a lot of questions in the net about linking OpenCV in CMake, e.g. this one: https://stackoverflow.com/questions/13970377/configuring-an-c-opencv-project-with-cmake. If you insist on using `pkg-config` approach, see that question: https://stackoverflow.com/questions/29191855/what-is-the-proper-way-to-use-pkg-config-from-cmake. – Tsyvarev Apr 28 '19 at 12:33
  • hi, @Tsyvarev thanks for replying. for the second link, I used the source to install my opencv. for the first, I have understood it but I will try. – MadLord Apr 29 '19 at 09:27
  • In your cmake, add CFLAGS+= `pkg-config opencv --cflags gstreamer-1.0 gstreamer-app-1.0` and also LIBS+=`pkg-config opencv --libs gstreamer-1.0` – Sai krishna Dec 12 '19 at 05:25

0 Answers0