-4

I'm jackaroo to learn how to train features of opencv, and I refer to these under url.

http://coding-robin.de/2013/07/22/train-your-own-opencv-haar-classifier.html


And above article author recommand to learn with his project, like here.

https://github.com/mrnugget/opencv-haar-classifier-training


And I study step by step, but in the same mould after I copy mergevec.cpp to my opencv apps's directory, like this

cp src/mergevec.cpp ~/opencv-2.4.9/apps/haartraining
cd ~/opencv-2.4.9/apps/haartraining

And then, I want to obtain executable file mergevec by using the following methods

g++ `pkg-config --libs --cflags opencv` -I. -o mergevec mergevec.cpp\
cvboost.cpp cvcommon.cpp cvsamples.cpp cvhaarclassifier.cpp\
cvhaartraining.cpp\
-lopencv_core -lopencv_calib3d -lopencv_imgproc -lopencv_highgui -lopencv_objdetect

And I get error

/tmp/cc9GpmMW.o: In function `JpgDatasetGenerator::JpgDatasetGenerator(char const*)':
cvhaartraining.cpp:(.text+0xafd5): undefined reference to `IOutput::createOutput(char const*, IOutput::OutputType)'
/tmp/cc9GpmMW.o: In function `PngDatasetGenerator::PngDatasetGenerator(char const*)':
cvhaartraining.cpp:(.text+0xb24d): undefined reference to `IOutput::createOutput(char const*, IOutput::OutputType)'
cvhaartraining.cpp:(.text+0xb24d): undefined reference to `IOutput::createOutput(char const*, IOutput::OutputType)'


I try to sovle the problem by looking through opecv forum's articles and found almost nothing.

So, um, could anybody help me? thanks a lot..

L.Jovi
  • 1,631
  • 4
  • 22
  • 36
  • this problem has nothing to do with opencv "an sich": it just means your file cannot find the implementation of the function "createOutput". Probably you should be linking to another object or library that contains it. – Chris Maes Dec 15 '14 at 10:20

1 Answers1

5

IOutput is an interface where their methods are declared at ioutput.h and must be implemented somewhere. I found out they were implemented at cvsamplesoutput.cpp so we just need ask gcc to compile that file. For that the correct command should be:

g++ `pkg-config --libs --cflags opencv` -I. -o mergevec mergevec.cpp\
cvboost.cpp cvcommon.cpp cvsamples.cpp cvhaarclassifier.cpp\
cvhaartraining.cpp cvsamplesoutput.cpp\
-lopencv_core -lopencv_calib3d -lopencv_imgproc -lopencv_highgui -lopencv_objdetect
  • It still gives me the linking error - ld: library not found for -llibtbb.dylib clang: error: linker command failed with exit code 1 (use -v to see invocation) – qgicup Aug 14 '15 at 13:16
  • If you're still having issues with the llibtbb.dylib file then take a look at this answer: http://stackoverflow.com/a/37259964/435040 – arturgrigor May 17 '16 at 08:49