【问题标题】:Ubuntu 14.04 Install opencv3.0, meet relocation errorUbuntu 14.04 安装opencv3.0,遇到重定位错误
【发布时间】:2015-05-29 18:32:08
【问题描述】:

这是我的制作日志:

[  3%] Built target libwebp
[  3%] Built target opencv_cudev
[  7%] Built target opencv_ts_pch_dephelp
[  7%] Built target pch_Generate_opencv_ts
[  7%] Built target opencv_core_pch_dephelp
[  7%] Built target pch_Generate_opencv_core
[ 11%] Built target opencv_core
[ 11%] Built target opencv_imgproc_pch_dephelp
[ 11%] Built target pch_Generate_opencv_imgproc
[ 15%] Built target opencv_imgproc
[ 15%] Built target opencv_imgcodecs_pch_dephelp
[ 15%] Built target pch_Generate_opencv_imgcodecs
[ 15%] Built target opencv_imgcodecs
[ 15%] Built target opencv_videoio_pch_dephelp
[ 15%] Built target pch_Generate_opencv_videoio
Linking CXX shared library ../../lib/libopencv_videoio.so
/usr/bin/ld: /usr/local/lib/libavformat.a(rmsipr.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libavformat.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [lib/libopencv_videoio.so.3.0.0] Error 1
make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
make: *** [all] Error 2

我尝试从源代码重新构建 ffmpeg,一开始,在 ffmpeg 中制作遇到了类似的问题,但在我使用此命令配置后:

./configure --prefix=.. --enable-shared --enable-gpl --enable-version3 --enable-runtime-cpudetect --disable-outdev=sdl --disable-opencl --enable-libmp3lame --enable-libx264 --cc="gcc -m64 -fPIC" --extra-cflags="-I../include" --extra-ldflags="-L../lib -ldl"

ffmpeg 已构建。

但是opencv make的错误依旧存在..

搜索了很多,找不到解决办法。

【问题讨论】:

  • 已解决:在配置期间使用 --enable-shared 标志重新制作 x264 和 ffmpeg。

标签: opencv ffmpeg


【解决方案1】:

基本上按照这个帖子重制x264和ffmpeg:http://www.ozbotz.org/opencv-installation-2-3-1/(配置x264和ffmpeg的时候记得加上--enable-shared)会解决这个问题。

【讨论】:

  • 如果使用 Ubuntu 提供的 libav 库,此解决方案将不起作用。这让我想知道为什么,因为提供的库是默认共享的。
猜你喜欢
  • 2015-07-26
  • 2015-12-21
  • 2016-10-18
  • 2017-01-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多