【问题标题】:ffmpeg install on CentOS 64-bit 'install with -fPIC' errorffmpeg 在 CentOS 64 位上安装“使用 -fPIC 安装”错误
【发布时间】:2012-03-19 08:20:42
【问题描述】:

尝试在 64 位 CentOS 机器上编译 ffmpeg 时出现此错误。

这是我的 ./configure 选项:

./configure --enable-shared --enable-gpl --enable-nonfree --enable-postproc --enable-swscale --enable-pthreads --enable-libx264 --enable-libxvid --enable-libvorbis --enable-libfaac --enable-libmp3lame --enable-libvpx

make

编译源码时出现如下错误:

/usr/bin/ld: /usr/local/lib/libvpx.a(vpx_codec.c.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/libvpx.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [libavcodec/libavcodec.so.54] Error 1

如何解决这个错误,并在我的 64 位 CentOS 机器上使用最新的 ffmpeg 启动并运行 libvpx?

【问题讨论】:

  • 有时当你运行 -fPIC 时,它会为某些子目标文件再次抛出此错误。只需备份该目标文件并再次运行 make 即可。例子。您正在运行 TotalSum.cpp,它引用了另一个文件 CalculateSum.o。现在,错误出现在CalculateSum.o 上。因此,还要备份CalculateSum.o 并运行-fPIC。错误会消失。

标签: linux ffmpeg 64-bit


【解决方案1】:

由于您使用“--enable-shared”配置了 FFMPEG,您还需要使用“--enable-shared”配置它的一些其他库,并且它们都必须使用相同的设置。

此错误消息基本上是告诉您在配置命令中添加“--enable-shared”再次编译 libvpx,然后尝试再次编译 FFMPEG(也使用“--enable-shared”进行配置)。很有可能您会收到相同的错误,但它会显示“libx264”或“libmp3lame”而不是“libvpx”,因此您还需要在配置命令中使用“--enable-shared”重新编译这些库。

【解决方案2】:

我在运行 Oracle Linux 6.3 的 x86_64 机器上编译 ffmpeg 时遇到了类似的错误。 Oracle Linux 基于 Red Hat,因此与原问题中的 CentOS 类似。

配置:

./configure --enable-shared --enable-nonfree --enable-libmp3lame --enable-libfaac --enable-libx264 --enable-encoder=x264 --enable-gpl

制作:

/usr/bin/ld: /usr/local/lib/libx264.a(common.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/libx264.a: could not read symbols: Bad value

在我的情况下,这个answer,虽然部分特定于 Ubuntu,但更多地阐明了一般 x86_64 系统的潜在问题:

“我相信如果你在 FFmpeg 上启用共享,你必须在 x86_64 系统上的 x264,否则您将拥有 PIC 共享 FFmpeg 和 非 PIC 静态 x264。”

修复是确保我最初使用带有 configure 的“--enable-static”标志编译的 x264 源代码(生成“/usr/local/lib/libx264.a”)使用“--enable-shared”标志重新编译,该标志生成“/usr/local/lib/libx264.so”的正确目标:

1st Attempt:
    1. cd /tmp
    2. wget ftp://ftp.videolan.org/pub/x264/snapshots/last_x264.tar.bz2
    3. tar xfv last_x264.tar.bz2; 
    4. cd x264-snapshot-xxxxxx
    5. ./configure --enable-static
    6. make && make install

2nd Attempt:
    1. cd /tmp/x264-snapshot-xxxxxx
    2. make distclean
    3. ./configure --enable-shared
    4. make && make install

【讨论】:

  • 确实这个答案告诉你做什么,而不是仅仅给你一个诊断
【解决方案3】:

试试

CFLAGS=-fPIC ./configure ...<your config options>...

添加错误提到的标志丢失。

【讨论】:

  • 这对我有用。关键是在构建/安装 x264/libx264 时也要使用这个标志。
【解决方案4】:

(问题是……?)

共享库必须由 PIC 对象代码组成,但 ffmpeg 未能做到。

【讨论】:

【解决方案5】:

您是否使用--shared-fPIC 编译了您的libvpx,所以它生成了libvpx.so*

如果没有,您可以在this 问题中尝试评论 #6 和 #7。

【讨论】:

【解决方案6】:

我在使用 libx264.a 构建 MythTV 时遇到了这个问题

我按照 Saheed 的建议下载并构建。

唯一的是 /usr/local/lib/libx264.a 在我执行“make install”时没有改变。我必须做“make install-lib-static”

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-01-20
    • 2016-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多