g++ error: undefined reference to CommandLineParser
I am new to opencv, and learning from "opencv by example" book.
I finished the installation and wanted to run an example : opencv_version.cpp as suggested. In the book it said I need to run this:
g++ -ggdb 'pkg-config --cflags --libs opencv3' opencv_version.cpp -o /tmp/opencv_version && /tmp/opencv_version
but afterward I got error saying that pkg-config ... is not found. After googling, apparently the problem is , I should use ` insetad of '
SO then I ran
g++ -ggdb `pkg-config --cflags --libs opencv3` opencv_version.cpp -o /tmp/opencv_version && /tmp/opencv_version
Yes It started compiling , but I got the following error:
/tmp/ccLwWorD.o: In function `main':
/home/osboxes/opencv-3.0.0/samples/cpp/opencv_version.cpp:12: undefined reference to `cv::CommandLineParser::CommandLineParser(int, char const* const*, cv::String const&)'
/home/osboxes/opencv-3.0.0/samples/cpp/opencv_version.cpp:14: undefined reference to `cv::CommandLineParser::has(cv::String const&) const'
AND SO ON
which in short is undefined reference to commandlineparser.
Here is some snapshot of the source code:
#include <opencv2/core/utility.hpp>
//some code here
cv::CommandLineParser parser(argc, argv, keys); //line 12
- Can anyone help me to fix the error?
- What does 'pkg-config --cflags --libs opencv3' do? what's its role?
- (ANSWERED, see edit)What does -ggdb in the g++ command mean/do? I googled it but couldn't find it?
----------EDIT
I found out the -ggdb part already :
Options starting with -g, -f, -m, -O, -W, or --param are automatically passed on to the various sub-processes invoked by g++.
So It meant to used gdb: which is a debugger
please try to use opencv3.1.
Hi @berak I now try opencv3.1 and followed the tutorials using gcc but another error appear. I posted a new question here .
Appreciate if you can help :)