GNU C Cross-compiler: Cannot execute binary file


I've been trying to compile busybox from source for ttylinux x64 I'm currently.. dealing with. Because of some king of bug (very similar to described here) I'm forced to use cross compiler.

But this thing refuses to work. When I try to run it:

$ /mnt/hdd/cross-compiler-x86_64/bin/x86_64-gcc --version

I get:

-bash: /mnt/hdd/cross-compiler-x86_64/bin/x86_64-gcc: cannot execute binary file

This is different diagnostic outputs:

$ ldd /mnt/hdd/cross-compiler-x86_64/bin/x86_64-gcc
not a dynamic executable

$ uname -mpi
x86_64 unknown unknown

$ uname -a
Linux ttylinux_host 3.7.1 #1 SMP Mon May 27 14:31:18 MST 2013 x86_64 GNU/Linux

$ objdump -f /mnt/hdd/cross-compiler-x86_64/bin/x86_64-gcc
/mnt/hdd/cross-compiler-x86_64/bin/x86_64-gcc: file format elf32-i386
architecture: i386, flags 0x00000112:
start address 0x08048188

Can anyone help me with this matter? I do believe x64 should have no problem running i386 code?

BTW: cross compiler originates from here

asked on Stack Overflow Apr 23, 2014 by user2838376

3 Answers


What is the origin of your cross compiler? Cross-native compilers are notorious for having dependencies on the architecture of the build-host of the toolchain. These go un-noticed until the toolchain is moved to a different architecture. You can move the runtime binary for any of the executables in the toolchain to some host that has the 'file' utility. This will probably tell you quite a lot, although the message from ldd is already suggesting that the binary is unacceptable to run on the present (or any?) architecture. The utility nm run against the binaries in the toolchain may be useful. If they all complain that the file(s) is/are not executable, then I think you will need to re-acquire a working toolchain.

answered on Stack Overflow Apr 23, 2014 by theNbomr

I think this is the answer:

 Try this:
 readelf --headers /mnt/hdd/cross-compiler-x86_64/bin/x86_64-gcc

 look for a line in the output that is something like:
 [Requesting program interpreter: /lib/ld-blahblah]

 Do you have the /lib/ld-blahblah file (for whatever blahblah really is) in the runtime environment? Most probably not. Make a symlink from what you see in the output above to what is actually on the machine.

To help clarify your question, you should make more clear about:

 Are you saying that ttylinux-x86_64 has gcc but it doesn't work? Or that ttylinux does not have gcc and you are NFS-mounting one?

And a hint to get better help than from here:

 Wouldn't it help if you asked the ttylinux maintainer?
answered on Stack Overflow Apr 28, 2014 by djerome • edited Apr 28, 2014 by djerome

This really looks like a kernel that is configured for pure 64-bit userspace, no i386 support.

This would be CONFIG_IA32_EMULATION in the kernel config. Check /proc/config.gz to confirm.

answered on Stack Overflow Apr 28, 2014 by (unknown user)

User contributions licensed under CC BY-SA 3.0