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

A1A*_*3A4 10 ffmpeg configure

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

我跑make./configure --enable-shared

这给了我以下消息:

/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 标志。

and*_*.46 6

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

andrew@ilium~/source/ffmpeg_build/ffmpeg/ffmpeg$ ./configure --help | grep -i pic
--enable-pic             build position-independent code
Run Code Online (Sandbox Code Playgroud)


小智 2

我已经解决了在 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
Run Code Online (Sandbox Code Playgroud)