Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » OpenCV application linker error
OpenCV application linker error [message #1808049] Fri, 14 June 2019 14:23 Go to next message
Sriram Chadalavada is currently offline Sriram ChadalavadaFriend
Messages: 1
Registered: June 2019
Junior Member
I successfully debugged the compilation errors but seeing this linker error. What is my
build missing?
This may well be a Newbie error, I'm using using Eclipse photon CDT for the first time.

Building file: ../YellowCircleDetect.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"YellowCircleDetect.d" -MT"YellowCircleDetect.o" -o "YellowCircleDetect.o" "../YellowCircleDetect.cpp"
Finished building: ../YellowCircleDetect.cpp

Building target: YellowcircleDetect
Invoking: GCC C++ Linker
g++ -L/usr/local/lib -o "YellowcircleDetect" ./YellowCircleDetect.o -lopencv_core\ opencv_imgproc\ opencv_highgui\ opencv_ml\ opencv_video\ opencv_features2d\ opencv_calib3d\ opencv_objdetect\ opencv_contrib\ opencv_legacy\ opencv_flann
/usr/bin/x86_64-linux-gnu-ld: cannot find -lopencv_core opencv_imgproc opencv_highgui opencv_ml opencv_video opencv_features2d opencv_calib3d opencv_objdetect opencv_contrib opencv_legacy opencv_flann
collect2: error: ld returned 1 exit status
makefile:44: recipe for target 'YellowcircleDetect' failed
make: *** [YellowcircleDetect] Error 1
"make all" terminated with exit code 2. Build might be incomplete.
Re: OpenCV application linker error [message #1808130 is a reply to message #1808049] Tue, 18 June 2019 03:19 Go to previous message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Your link is concatenating all the lib names separated by spaces.
That's what the backslash in the link command is doing.
There is no library named: "opencv_core\ opencv_imgproc\ opencv_highgui ..."
But there is one named:libopencv_core.a , etc.

What you want is something more like:
-lopencv_shape -lopencv_stitching -lopencv_superres 
-lopencv_videostab -lopencv_aruco -lopencv_bgsegm 
-lopencv_bioinspired -lopencv_ccalib -lopencv_cvv 
: :: etc. etc.
 -lopencv_xphoto -lopencv_imgproc -lopencv_core 

Not sure how you gave the libraries to Eclipse.
If you have pkg-config you can use it in the link command
assuming you are using Linux (which looks like you are).
I'm also assuming you are using a Managed Build (i.e., Eclipse is creating the makefile).

Add `pkg-config --libs opencv` (Note: those are backticks) to the linker misc. options at
Project --> Properties --> C/C++ Build --> Settings --> Tool Settings tab --> <linker> --> Miscellaneous

If you don't have pkg-config or can't use it for some reason then
you;'l have to give them to Eclipse manually at
Project --> Properties --> C/C++ Build --> Settings --> Tool Settings tab --><compiler>--> Includes
Don't include the -l part. Eclipse will do that for you.

Also, when setting the tool options, make sure you have selected the proper build configuration at the top of the dialog.

[Updated on: Tue, 18 June 2019 03:20]

Report message to a moderator

Previous Topic:C/C++ Unit optional plugin - question & suggestion
Next Topic:Cannot import library file from ESP32 sdk folder in "Eclipse C++ IDE for Arduino" project
Goto Forum:
  


Current Time: Tue Sep 24 20:42:14 GMT 2024

Powered by FUDForum. Page generated in 0.03691 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top