OpenCV2.4.9 version of the compiler

Compiler directives

Create a library directory: mkdir install

Create a build directory: mkdir build

Enter the directory: cd build

Execution generated Makefile:


cmake -D WITH_CUDA=OFF \
            -D CMAKE_BUILD_TYPE=Release \
            -D CMAKE_INSTALL_PREFIX=cmake -D WITH_CUDA=OFF \
            -D CMAKE_BUILD_TYPE=Release \
            -D CMAKE_INSTALL_PREFIX=/home/packages/opencv/install \
            -D WITH_IPP=OFF \
            -D WITH_FFMPEG=ON  \
            -D BUILD_TESTS=OFF \
            -D BUILD_PERF_TESTS=OFF \
            -D INSTALL_PYTHON_EXAMPLES=OFF \
            -D INSTALL_C_EXAMPLES=OFF \
            -D PYTHON_EXECUTABLE=$(which python) \
            -D BUILD_EXAMPLES=OFF .. \
            -D WITH_IPP=OFF \
            -D WITH_FFMPEG=ON  \
            -D BUILD_TESTS=OFF \
            -D BUILD_PERF_TESTS=OFF \
            -D INSTALL_PYTHON_EXAMPLES=OFF \
            -D INSTALL_C_EXAMPLES=OFF \
            -D PYTHON_EXECUTABLE=$(which python) \
            -D BUILD_EXAMPLES=OFF ..


Generating installation: make && make install


Compile abnormal

1)[ 98%] Linking CXX executable ../../bin/opencv_performance
../../lib/libopencv_highgui.so.2.4.9: undefined reference to `avcodec_alloc_frame'
../../lib/libopencv_highgui.so.2.4.9: undefined reference to `avcodec_encode_video'
collect2: error: ld returned 1 exit status
apps/haartraining/CMakeFiles/opencv_performance.dir/build.make:105: recipe for target 'bin/opencv_performance' failed
make[2]: *** [bin/opencv_performance] Error 1
CMakeFiles/Makefile2:3388: recipe for target 'apps/haartraining/CMakeFiles/opencv_performance.dir/all' failed
make[1]: *** [apps/haartraining/CMakeFiles/opencv_performance.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2

问题:undefined reference to `avcodec_alloc_frame'

-R through grep " avcodec_alloc_frame " / global text query returns empty

The latest version of FFmpeg realize the name of the function has changed, download the source code to compile ffmpeg-2.3.tar.bz2

2) has been compiled ffmpeg-2.3.tar.bz2 , generate libswresample.so.0 not be found, the libswresample.so.0 down to copy / lib64 directory

/usr/bin/ld: warning: libswresample.so.0, needed by //home/dong/ffmpeg/ffmpeg-2.3/build/lib/libavcodec.so.55, not found (try using -rpath or -rpath-link)
//home/dong/ffmpeg/ffmpeg-2.3/build/lib/libavcodec.so.55: undefined reference to `swr_init@LIBSWRESAMPLE_0'
//home/dong/ffmpeg/ffmpeg-2.3/build/lib/libavcodec.so.55: undefined reference to `swr_close@LIBSWRESAMPLE_0'
//home/dong/ffmpeg/ffmpeg-2.3/build/lib/libavcodec.so.55: undefined reference to `swr_is_initialized@LIBSWRESAMPLE_0'
//home/dong/ffmpeg/ffmpeg-2.3/build/lib/libavcodec.so.55: undefined reference to `swr_free@LIBSWRESAMPLE_0'
//home/dong/ffmpeg/ffmpeg-2.3/build/lib/libavcodec.so.55: undefined reference to `swr_alloc@LIBSWRESAMPLE_0'
//home/dong/ffmpeg/ffmpeg-2.3/build/lib/libavcodec.so.55: undefined reference to `swr_convert@LIBSWRESAMPLE_0'
collect2: error: ld returned 1 exit status
apps/haartraining/CMakeFiles/opencv_performance.dir/build.make:105: recipe for target 'bin/opencv_performance' failed
make[2]: *** [bin/opencv_performance] Error 1
CMakeFiles/Makefile2:3388: recipe for target 'apps/haartraining/CMakeFiles/opencv_performance.dir/all' failed
make[1]: *** [apps/haartraining/CMakeFiles/opencv_performance.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error

3)export PKG_CONFIG_PATH=/home/dong/opencv-2.4.9/install/lib/pkgconfig/;$PKG_CONFIG_PATH

Specifies the first search OpenCV compiled FFmpeg, FFmpeg library system rather than

Guess you like

Origin blog.51cto.com/fengyuzaitu/2465842