I get the following linker error :
/tmp/cclOj2K8.o: In function `main':
fontTest.cpp:(.text+0x96): undefined reference to `cv::fontQt(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, cv::Scalar_<double>, int, int, int)'
fontTest.cpp:(.text+0x151): undefined reference to `cv::addText(cv::Mat const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::Point_<int>, CvFont)'
collect2: ld returned 1 exit status
To compile I type:
gcc `pkg-config --cflags opencv` `pkg-config --libs opencv` -o fontTest fontTest.cpp
I do have openCV 2.3.1 installed.
Here is my source code (fontTest.cpp):
#include <cv.h>
#include <highgui.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
using namespace cv;
int main(int argc, char* argv[]) {
Mat img1;
CvFont font = fontQt("Times");
addText( img1, "Hello World !", Point(50,50), font);
imshow("image", img1);
waitKey(0);
}
The output of the pkg-config are:
-L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann
-I/usr/local/include/opencv -I/usr/local/include
What am I missing?
Thanks for the help.
I had the same problem. It turned out that I had not enabled QT (WITH_QT=ON) when compiling OpenCV.