Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

OpenCV2.4.9 version compilation

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

1) linux to view the opencv installation path and version number

View the opencv installation library under linux:

Pkg-config opencv-libs

View the installation version of opencv under linux:

Pkg-config opencv-modversion

View the opencv installation path under linux:

Find /-iname "* opencv*"

2) compile instruction

Create a library directory: mkdir install

Create a build directory: mkdir build

Enter the directory: cd build

Execute the generate 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..

Generate installation: make & & make install

Compilation exception

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

Problem: undefined reference to `avcodec_alloc_frame'

Return null via grep-r "avcodec_alloc_frame" / query global text

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

2) ffmpeg-2.3.tar.bz2 has been compiled, but the generated libswresample.so.0 cannot be found. Copy the libswresample.so.0 to the / 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 that OpenCV first finds the compiled FFmpeg rather than the system's FFmpeg library

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report