[FFmpeg-user] Problem building with OpenCV support

Misha Penkov misha.penkov at gmail.com
Wed Jun 27 13:53:27 CEST 2012


On 27 June 2012 20:25, Carl Eugen Hoyos <cehoyos at ag.or.at> wrote:
> Misha Penkov <misha.penkov <at> gmail.com> writes:
>
>> >  #include <opencv/cxcore.h>
>> >  long check_cvCreateImageHeader(void) { return (long) cvCreateImageHeader; }
>> >  int main(void) { return 0; }
>>
>> That would have made more sense than my original sample. Thank you
>> for your suggestion.  Unfortunately, the result is the same:
>
> The I suggest you try to find out what the difference is between
> what you do and what configure does (see end of config.log).

Good idea.  Everything compiles as expected until the final linking
step.  Then, when I try to link using:

mpenkov at misha-desktop:~/Desktop$ gcc -Wl,--as-needed
-I/usr/local/include/opencv -I/usr/local/include
/usr/local/lib/libopencv_calib3d.so
/usr/local/lib/libopencv_contrib.so /usr/local/lib/libopencv_core.so
/usr/local/lib/libopencv_features2d.so
/usr/local/lib/libopencv_flann.so /usr/local/lib/libopencv_gpu.so
/usr/local/lib/libopencv_highgui.so
/usr/local/lib/libopencv_imgproc.so /usr/local/lib/libopencv_legacy.so
/usr/local/lib/libopencv_ml.so /usr/local/lib/libopencv_nonfree.so
/usr/local/lib/libopencv_objdetect.so
/usr/local/lib/libopencv_photo.so
/usr/local/lib/libopencv_stitching.so /usr/local/lib/libopencv_ts.so
/usr/local/lib/libopencv_video.so
/usr/local/lib/libopencv_videostab.so -o check.out check.o
-lopencore-amrwb -lopencore-amrnb -lmp3lame -lfaac -lm -pthread -lbz2
-lz -lrt

check.o: In function `cvDecRefData':
check.c:(.text+0xc2d): undefined reference to `cvFree_'
check.c:(.text+0xcc4): undefined reference to `cvFree_'
check.o: In function `cvGetRow':
check.c:(.text+0xdf7): undefined reference to `cvGetRows'
check.o: In function `cvGetCol':
check.c:(.text+0xe30): undefined reference to `cvGetCols'
check.o: In function `cvReleaseMatND':
check.c:(.text+0xe4c): undefined reference to `cvReleaseMat'
check.o: In function `cvSubS':
check.c:(.text+0xfd0): undefined reference to `cvAddS'
check.o: In function `cvCloneSeq':
check.c:(.text+0x100f): undefined reference to `cvSeqSlice'
check.o: In function `cvSetNew':
check.c:(.text+0x1088): undefined reference to `cvSetAdd'
check.o: In function `cvGetSetElem':
check.c:(.text+0x1145): undefined reference to `cvGetSeqElem'
check.o: In function `cvEllipseBox':
check.c:(.text+0x125a): undefined reference to `cvEllipse'
check.o: In function `cvFont':
check.c:(.text+0x129e): undefined reference to `cvInitFont'
check.o: In function `cvReadIntByName':
check.c:(.text+0x13a1): undefined reference to `cvGetFileNodeByName'
check.o: In function `cvReadRealByName':
check.c:(.text+0x1464): undefined reference to `cvGetFileNodeByName'
check.o: In function `cvReadStringByName':
check.c:(.text+0x14f7): undefined reference to `cvGetFileNodeByName'
check.o: In function `cvReadByName':
check.c:(.text+0x153c): undefined reference to `cvGetFileNodeByName'
check.c:(.text+0x1553): undefined reference to `cvRead'
check.o: In function `check_cvCreateImageHeader':
check.c:(.text+0x155f): undefined reference to `cvCreateImageHeader'
collect2: ld returned 1 exit status

In other words, I get the same errors that configure runs into.  If I
do this instead (don't specify the --as-needed flag), then everything
links fine:

mpenkov at misha-desktop:~/Desktop$ gcc -Wl,--as-needed
-I/usr/local/include/opencv -I/usr/local/include
/usr/local/lib/libopencv_calib3d.so
/usr/local/lib/libopencv_contrib.so /usr/local/lib/libopencv_core.so
/usr/local/lib/libopencv_features2d.so
/usr/local/lib/libopencv_flann.so /usr/local/lib/libopencv_gpu.so
/usr/local/lib/libopencv_highgui.so
/usr/local/lib/libopencv_imgproc.so /usr/local/lib/libopencv_legacy.so
/usr/local/lib/libopencv_ml.so /usr/local/lib/libopencv_nonfree.so
/usr/local/lib/libopencv_objdetect.so
/usr/local/lib/libopencv_photo.so
/usr/local/lib/libopencv_stitching.so /usr/local/lib/libopencv_ts.so
/usr/local/lib/libopencv_video.so
/usr/local/lib/libopencv_videostab.so -o check.out check.o
-lopencore-amrwb -lopencore-amrnb -lmp3lame -lfaac -lm -pthread -lbz2
-lz -lrt

--as-needed isn't in my man gcc, but I googled around and found this:

http://sigquit.wordpress.com/2011/02/16/why-asneeded-doesnt-work-as-expected-for-your-libraries-on-your-autotools-project/

I'm really not that flash with autotools, so I didn't exactly
understand what's going on here.  From all I can tell, somehow the
--as-needed flag is fooling the linker into thinking it doesn't need
the opencv libraries, when it actually does.  What should I try next?

Thanks for your help so far, by the way.

Cheers,
Michael

>
> Carl Eugen
>
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user


More information about the ffmpeg-user mailing list