编译ffmpeg时出错:gcc无法创建可执行文件

Omi*_*mid 5 ubuntu gcc ffmpeg

当我./configure在 ffmpeg 源目录中运行命令时,出现此错误:

gcc is unable to create an executable file. If gcc is a cross-compiler, use the --enable-cross-compile option. Only do this if you know what cross compiling means. C compiler test failed.

If you think configure made a mistake, make sure you are using the latest version from Git.  If the latest version fails, report the problem to the ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net. Include the log file "config.log" produced by configure as this will help solving the problem.
Run Code Online (Sandbox Code Playgroud)

在 config.log 中:

check_ld cc
check_cc
BEGIN /tmp/ffconf.xECiIX7z.c
    1   int main(void){ return 0; }
END /tmp/ffconf.xECiIX7z.c
gcc -c -o /tmp/ffconf.xsCaoMWN.o /tmp/ffconf.xECiIX7z.c
gcc -o /tmp/ffconf.ApzYq7NQ /tmp/ffconf.xsCaoMWN.o
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x12): undefined reference to `__libc_csu_fini'
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x19): undefined reference to `__libc_csu_init'
collect2: ld returned 1 exit status
C compiler test failed.
Run Code Online (Sandbox Code Playgroud)

怎么了?我该怎么办?

bah*_*mat 6

这意味着您没有必要的软件来编译 C 代码。

运行这个:

apt-get install build-essential
Run Code Online (Sandbox Code Playgroud)

您还需要 ffmpeg 的构建依赖项:

apt-get build-dep ffmpeg
Run Code Online (Sandbox Code Playgroud)

然后再试一次。


Ala*_*rry 4

您的 libc 安装不完整或以某种方式损坏。您应该说明您使用的操作系统...最简单的解决方法可能是重新安装包含 libc 的软件包。

或者,如果您确实有兴趣找出到底是哪个部分损坏了,这里有一些提示:

__libc_csu_init在典型的 glibc 安装中,对和 的引用__libc_csu_fini将通过查找它们来解决,/usr/lib/libc_nonshared.a您可以在其中检查如下:

$ nm /usr/lib/libc_nonshared.a | egrep '__libc_csu_(init|fini)'
0000000000000000 T __libc_csu_fini
0000000000000010 T __libc_csu_init
Run Code Online (Sandbox Code Playgroud)

的使用将通过链接到(这是一个文本文件,而不是实际的共享对象)/usr/lib/libc_nonshared.a来触发。/usr/lib/libc.so你可以这样检查:

里面可能还有一些其他的东西。你可以检查一下

$ less /usr/lib/libc.so
[...]
GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a )
Run Code Online (Sandbox Code Playgroud)

/usr/lib/libc.so链接器将使用它来满足-lc要求,您可以像这样检查:

$ ld --verbose -lc
[... lots of stuff ...]
opened script file /usr/lib64/libc.so
attempt to open /lib/libc.so.6 succeeded
/lib/libc.so.6
attempt to open /usr/lib/libc_nonshared.a succeeded
Run Code Online (Sandbox Code Playgroud)