1

I'm trying to compile my own object detector by using OpenCV 3 hog and svm over Eclipse CDT but when compiling the console returns the following:

Building target: HogDetection
Invoking: GCC C++ Linker
g++ -L/usr/local/lib -o "HogDetection"  ./main.o ./phog.o ./psvm.o   -lopencv_core -lopencv_imgcodecs -lopencv_highgui -lopencv_ml
./phog.o: In function `cv::HOGDescriptor::HOGDescriptor()':
/usr/local/include/opencv2/objdetect.hpp:348: undefined reference to `vtable for cv::HOGDescriptor'
./phog.o: In function `cv::HOGDescriptor::~HOGDescriptor()':
/usr/local/include/opencv2/objdetect.hpp:372: undefined reference to `vtable for cv::HOGDescriptor'
collect2: error: ld returned 1 exit status
make: *** [HogDetection] Error 1

Probably I'm doing something wrong with the libraries but since I'm new both to c++ and OpenCV I followed a tutorial to set up eclipse CDT with openCV and I was able to run other simple tutorials (those on openCV websites like display image and so on...).

I also read something on wikipedia about vtable and here but it was not sufficient for me to understand what's happening here. Thanks in advance.

Dario
  • 331
  • 4
  • 16
  • possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Emil Laine Jun 12 '15 at 11:40
  • similar error solved here: [http://stackoverflow.com/questions/9955972/problems-using-hogdescriptor](http://stackoverflow.com/questions/9955972/problems-using-hogdescriptor). – MisterC Jun 12 '15 at 11:44
  • @MisterC your answer solved my problem, I just add opencv_objdetect to the linker. – Dario Jun 12 '15 at 14:53
  • @zenith thanks for your usefull answer but it is too general for a noob like me. It will help me in improving my knowledge. – Dario Jun 12 '15 at 14:55

2 Answers2

4

I solved the problem by adding to the gcc c++ linker libraries the library opencv_objdetect

Dario
  • 331
  • 4
  • 16
1

Well if you are working with make files then just add
LIBS += -L/usr/local/libs \ -lopencv_objdetect \

or if you are not having makefile then just run code like
g++ -Wall main.cpp /usr/lib/libopencv_objdetect.a -o main

pyAddict
  • 1,576
  • 13
  • 15