2

我正在尝试在 Ubuntu 14.10 上安装 OpenCV,但我一次又一次地面临这个错误:(

    /usr/bin/ld: /usr/local/lib/libavcodec.a(avpacket.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
    /usr/local/lib/libavcodec.a: error adding symbols: Bad value
    collect2: error: ld returned 1 exit status
    modules/highgui/CMakeFiles/opencv_highgui.dir/build.make:654: recipe for target 'lib/libopencv_highgui.so.2.4.9' failed
    make[2]: *** [lib/libopencv_highgui.so.2.4.9] Error 1
    CMakeFiles/Makefile2:1767: recipe for target 'modules/highgui/CMakeFiles/opencv_highgui.dir/all' failed
    make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
    Makefile:133: recipe for target 'all' failed
    make: *** [all] Error 2
4

2 回答 2

0

请在遇到错误之前提供命令历史记录。

如果调用make是错误发生之前的最后一件事,您可以尝试调用make CFLAGS="-fPIC"

于 2015-02-26T22:05:51.097 回答
0

迟到了,但问题是 FFMPEG 不是用与位置无关的代码编译的。转到您的 FFMPEG 目录并执行

./configure --enable-nonfree --enable-pic --enable-shared

然后重做makemake install步骤,并重新构建opencv。

于 2017-10-02T18:51:37.223 回答