[solved] Undefined reference to `cvFloodFill' (linux32)

hey there,

I’m trying to build an old addon example of mine. the addon depends on ofxOpenCv. the opencv example works fine but with my addon I get an undefined reference to cvFloodFill:

../../../addons/ofxOpenCv/libs/opencv/lib/linux/libopencv_video.a(motempl.o): In function `cvSegmentMotion':
make[1]: Leaving directory `/home/felix/oF/openFrameworks/addons/ofxCvMotionTemplates/example-motion'
motempl.cpp:(.text.cvSegmentMotion+0x75c): undefined reference to `cvFloodFill'

I think the setup of my example should be fine - perhaps the libs are broken for this particular part (cvSegmentMotion -> cvFloodFill)? I’m on Ubuntu 12.04 32bit.

Any ideas?

Best,
Felix

If I add:

cvFloodFill(NULL, CvPoint(), cvScalarAll(0));

im my testApp::setup() the linking works. Don’t get it!?! Also if I only add

cvSegmentMotion(NULL, NULL, NULL, 0,0);

to the opencv-example the linking fails there, too. But together with the cvFloodFill dummy call - all fine.

in linux you need to add your addon and ofxOpenCv in addons.make

hey @arturo,

sure I did that. it’s not the point. I reproduced the undefined reference in the distributed opencv example just by adding a dummy cvSegmentMotion() call, which is part of opencv.

//--------------------------------------------------------------
void ofApp::setup(){
	cvSegmentMotion(NULL, NULL, NULL, 0,0);
	//cvFloodFill(NULL, CvPoint(), cvScalarAll(0));

if I uncomment the cvFloodFill call the linking is working again. I guess the lib/linux/libopencv_video.a is kind of broken and the linking fails only if you use some of the motempl.o (motion templates) stuff.

but why the workaround with calling cvFloodFill directly works - I have no clue.

Best,
Felix

ah ok, it’s probably related to the order in which libraries are linked, try changing it in ofxOpenCv/addon_config.mk libraries that depend on others should go before not after.

2 Likes

jep that’s it. thanks a lot. video (cvSegmentMotion) before imgproc (cvFloodFill). I had thought it would be the other way around.

I’ll send a pull request.