Jithin Pavithran
Jithin Pavithran

Reputation: 1351

Undefined reference to `cvCreateBGCodeBookModel'

I'm getting following the error message when compiling C++ Code.

$g++ basic100.cpp -o test -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_objdetect
/tmp/ccWqj7E2.o: In function `main':
basic100.cpp:(.text+0x67): undefined reference to `cvCreateBGCodeBookModel'
basic100.cpp:(.text+0x2c6): undefined reference to `cvBGCodeBookUpdate'
basic100.cpp:(.text+0x31d): undefined reference to `cvBGCodeBookClearStale'
basic100.cpp:(.text+0x374): undefined reference to `cvBGCodeBookDiff'
basic100.cpp:(.text+0x3c8): undefined reference to `cvSegmentFGMask'
collect2: error: ld returned 1 exit status

The Code worked fine in my friend's laptop. My system is 32bit Linux Mint while they have 64bit Ubuntu 14.04.

Compilation command used in my friend's laptop $ g++ -o fff basic100.cpp pkg-config --cflags --libs opencv

This is how I used cvCreateBGCodeBoolModel()

(model definition :CvBGCodeBookModel* model = 0;//outside main())

    model = cvCreateBGCodeBookModel();

Upvotes: 1

Views: 511

Answers (2)

Lonewolf
Lonewolf

Reputation: 66

It may be that you lack some of the header files.try making the codebook structure yourself .with opencv 3.0 your code wont work since there you have to use the BackgrundSubtractorMOG class

Upvotes: 0

rabensky
rabensky

Reputation: 2934

When I run the command

grep cvCreateBGCodeBookModel /usr/lib/x86_64-linux-gnu/libopencv_*.so

I get the result

Binary file /usr/lib/x86_64-linux-gnu/libopencv_legacy.so matches

So I assume you're missing the -lopencv_legacy flag in the compilation. But I have a 64 bit system.

Can you check and see if that works?

Upvotes: 1

Related Questions