Ubuntu – error while compiling ffmpeg: gcc is unable to create an executable file

ffmpeggccUbuntu

When I run the ./configure command in ffmpeg source directory I get this error:

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.

in 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.

What's wrong? What should I do?

Best Answer

Your libc installation is incomplete or broken somehow. You should say what OS you use... the easiest fix is probably to reinstall the packages that comprise the libc.

Or if you are really interested in finding out exactly which part of it is broken, here are some tips:

On a typical glibc installation, the references to __libc_csu_init and __libc_csu_fini will be resolved by finding them in /usr/lib/libc_nonshared.a which you can check as follows:

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

The use of /usr/lib/libc_nonshared.a will be triggered by linking to /usr/lib/libc.so (which is a text file, not an actual shared object). You can check that like this:

There may be some other stuff in it too. You can check that with

$ less /usr/lib/libc.so
[...]
GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a )

/usr/lib/libc.so will be used by the linker to satisfy the -lc requirement, which you can check like this:

$ 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
Related Question