如何处理“使用-fPIC重新编译”消息

我正在尝试配置ffmpeg源包来构建.so文件而不是.a文件。

我在执行./configure --enable-shared之后运行make

这给了我以下信息:

/usr/bin/ld: libavutil/display.o: relocation R_X86_64_PC32 against undefined symbol 'hypot@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC

但是,我不确定在何处以及如何添加-fPIC标志。

有一个./configure选项可能是解决问题的最简单方法:

 andrew@ilium~/source/ffmpeg_build/ffmpeg/ffmpeg$ ./configure --help | grep -i pic --enable-pic build position-independent code 

我已经解决了在Ubuntu 14.04 LTS编译FFMpeg 2.3.3源时出现的相同错误。 在将LD_LIBRARY_PATH设置为/usr/lib/x86_64-linux-gnu并将-fPIC标志添加到--cc后,我成功编译了代码。 我的工作编译命令在这里:

 LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu ./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" make -j4 

重定位R_X86_64_PC32对未定义的符号,通常在LDFLAGS设置为加固而CFLAGS没有设置时发生。
也许只是用户错误:
如果在链接时使用-specs = / usr / lib / rpm / redhat / redhat-hardened-ld,则还需要在编译时使用-specs = / usr / lib / rpm / redhat / redhat-hardened-cc1 ,当你同时编译和链接时,你需要两者,或者删除-specs = / usr / lib / rpm / redhat / redhat-hardened-ld。 常见修复:
https://bugzilla.redhat.com/show_bug.cgi?id=1304277#c3
https://github.com/rpmfusion/lxdream/blob/master/lxdream-0.9.1-implicit.patch