189 8069 5689

OpenCV2.4.9版本编译-创新互联

1)linux查看opencv安装路径及版本号
查看linux下的opencv安装库:
pkg-config opencv --libs
查看linux下的opencv安装版本:
pkg-config opencv --modversion
查看linux下的opencv安装路径:
find / -iname "*opencv*"

为鲁山等地区用户提供了全套网页设计制作服务,及鲁山网站建设行业解决方案。主营业务为网站制作、网站建设、鲁山网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!

2)编译指令

创建库目录:    mkdir install

创建生成目录 :   mkdir build

进入目录: cd build

执行生成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 ..

生成安装:make && make install

编译异常

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'

通过grep -r "avcodec_alloc_frame"  / 查询全局文本返回空

最新版本的FFmpeg该函数的实现名称已经改变,下载ffmpeg-2.3.tar.bz2源码编译

2)已经编译ffmpeg-2.3.tar.bz2,生成libswresample.so.0无法找到,将libswresample.so.0拷贝到/lib64目录下

/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

指定OpenCV优先查找编译好的FFmpeg,而不是系统的FFmpeg库

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


当前题目:OpenCV2.4.9版本编译-创新互联
网页路径:http://cdxtjz.cn/article/pgjje.html

其他资讯