[FFmpeg-user] static link including opencv

Mark Himsley mark at mdsh.com
Fri Nov 25 19:25:29 CET 2011


I'd like a hint on including opencv in a static FFmpeg.

This is using FFmpeg git head and OpenCV-2.3.1a.

I built opencv with these settings:

cmake \
  -D CMAKE_BUILD_TYPE=RELEASE \
  -D BUILD_SHARED_LIBS=OFF \
  -D WITH_FFMPEG=OFF \
  -D BUILD_TESTS=OFF \
  -D CMAKE_INSTALL_PREFIX=$PREFIX \
  ../OpenCV-2.3.1/
make
sudo make install


I'm configuring FFmbc with this ($PREFIX is /usr/local)

/configure \
  --arch=x86 \
  --cpu=i686 \
  --enable-static \
  --extra-cflags='--static -I$PREFIX/include' \
  --extra-libs='-static -L$PREFIX/lib' \
  --prefix=$PREFIX \
  --disable-ffplay \
  --disable-ffprobe \
  --enable-gpl \
  --enable-version3 \
  --enable-nonfree \
  --enable-pthreads \
  --enable-x11grab \
  --enable-libdirac \
  --enable-libfaac \
  --enable-libgsm \
  --enable-libmp3lame \
  --enable-libopenjpeg \
  --enable-libspeex \
  --enable-libtheora \
  --enable-libvorbis \
  --enable-libvpx \
  --enable-libxvid \
  --enable-libopencv


In order for ./configure to complete I had to edit 
/usr/local/lib/pkgconfig/opencv.pc to add -ltr to the end of the the 
Libs: line.

But now making FFmpeg, all goes well until the link:

$ make V=1
[...]
gcc -Llibavcodec -Llibavdevice -Llibavfilter -Llibavformat -Llibavutil 
-Llibpostproc -Llibswscale -Llibswresample -Wl,--as-needed 
-Wl,--warn-common 
-Wl,-rpath-link=libpostproc:libswresample:libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil 
-o ffmpeg_g ffmpeg.o cmdutils.o -lavdevice -lavfilter -lavformat 
-lavcodec -lpostproc -lswresample -lswscale -lavutil -ldl -lxvidcore 
-lvpx -lvpx -lvorbisenc -lvorbis -logg -ltheoraenc -ltheoradec -logg 
-lspeex -lopenjpeg -L/usr/local/lib -lopencv_core -lopencv_imgproc 
-lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d 
-lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy 
-lopencv_flann -lrt -lmp3lame -lgsm -lfaac -ldirac_encoder 
-ldirac_decoder -lm -lstdc++ -lm -pthread -lbz2 -lz -static 
-L/usr/local/lib
/usr/local/lib/libopencv_core.a(system.o): In function 
`cv::tempfile(char const*)':
system.cpp:(.text._ZN2cv8tempfileEPKc+0x3a): warning: the use of 
`tmpnam' is dangerous, better use `mkstemp'
libavformat/libavformat.a(rtsp.o): In function `get_sockaddr':
/home/himslm01/src/ffmpeg/libavformat/rtsp.c:160: warning: Using 
'getaddrinfo' in statically linked applications requires at runtime the 
shared libraries from the glibc version used for linking
/usr/local/lib/libopencv_imgproc.a(templmatch.o): In function 
`cv::crossCorr(cv::Mat const&, cv::Mat const&, cv::Mat&, cv::Size_<int>, 
int, cv::Point_<int>, double, int)':
templmatch.cpp:(.text._ZN2cv9crossCorrERKNS_3MatES2_RS0_NS_5Size_IiEEiNS_6Point_IiEEdi+0x412): 
undefined reference to `cv::getOptimalDFTSize(int)'
templmatch.cpp:(.text._ZN2cv9crossCorrERKNS_3MatES2_RS0_NS_5Size_IiEEiNS_6Point_IiEEdi+0x445): 
undefined reference to `cv::getOptimalDFTSize(int)'
templmatch.cpp:(.text._ZN2cv9crossCorrERKNS_3MatES2_RS0_NS_5Size_IiEEiNS_6Point_IiEEdi+0xded): 
undefined reference to `cv::dft(cv::_InputArray const&, cv::_OutputArray 
const&, int, int)'
templmatch.cpp:(.text._ZN2cv9crossCorrERKNS_3MatES2_RS0_NS_5Size_IiEEiNS_6Point_IiEEdi+0x1b2e): 
undefined reference to `cv::dft(cv::_InputArray const&, cv::_OutputArray 
const&, int, int)'
templmatch.cpp:(.text._ZN2cv9crossCorrERKNS_3MatES2_RS0_NS_5Size_IiEEiNS_6Point_IiEEdi+0x1bf6): 
undefined reference to `cv::mulSpectrums(cv::_InputArray const&, 
cv::_InputArray const&, cv::_OutputArray const&, int, bool)'
templmatch.cpp:(.text._ZN2cv9crossCorrERKNS_3MatES2_RS0_NS_5Size_IiEEiNS_6Point_IiEEdi+0x1c38): 
undefined reference to `cv::dft(cv::_InputArray const&, cv::_OutputArray 
const&, int, int)'
collect2: ld returned 1 exit status
make: *** [ffmpeg_g] Error 1

Any ideas?

-- 
Mark


More information about the ffmpeg-user mailing list