2

[Thank you everyone!., sorry i didn't see the mismatched kernel, for some reason i was thinking this was my ubuntu server 64 bit]

I compiled a custom gcc tool chain using ct-ng, compilation was successful but i wrote a simple hello world and i see this error

Could someone, please point me what is wrong here and why i get this error?

Error:

src/main$ ./main 
bash: ./main: cannot execute binary file

About OS

uname -a
Linux lnx-server 3.2.0-25-generic-pae #40-Ubuntu SMP Wed May 23 22:11:24 UTC 2012 i686 i686 i386 GNU/Linux

Some additional info on the file

src/main$ file main
main: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, not stripped

File permission

-rwxrwxr-x 1 balravin balravin  8276 Jul 27 17:45 main

Command used to compile

src/main$ x86_64-mvl-linux-gnu-gcc -o main main2.c

GCC configuration

> src/main$ x86_64-mvl-linux-gnu-gcc --v Using built-in specs. Target:
> x86_64-mvl-linux-gnu Configured with:
> /home/balravin/tools/platform/x86/src/gnu/gcc/4.2.4/.build/src/gcc-4.2.4/configure
> --build=i686-build_pc-linux-gnu --host=i686-build_pc-linux-gnu --target=x86_64-mvl-linux-gnu --prefix=/home/balravin/tools/platform/x86/obj/gnu/gcc/4.2.4/x86_64-mvl-linux-gnu
> --with-sysroot=/home/balravin/tools/platform/x86/obj/gnu/gcc/4.2.4/x86_64-mvl-linux-gnu/x86_64-mvl-linux-gnu/sysroot
> --enable-languages=c,c++ --disable-sjlj-exceptions --enable-__cxa_atexit --enable-libmudflap --enable-libgomp --enable-libssp --enable-threads=posix --enable-target-optspace --with-long-double-128 --disable-nls --disable-multilib --with-local-prefix=/home/balravin/tools/platform/x86/obj/gnu/gcc/4.2.4/x86_64-mvl-linux-gnu/x86_64-mvl-linux-gnu/sysroot
> --enable-c99 --enable-long-long Thread model: posix gcc version 4.2.4

And finally main2.c

#include <stdio.h>
int main() {

    printf("\nHello Work\n");
    return 0;
}

2 Answers 2

4

Your kernel is 32-bit, and you have compiled a 64-bit binary. You need a 64-bit kernel on 64-bit hardware in order to run a 64-bit binary.

Sign up to request clarification or add additional context in comments.

Comments

2

You're trying to run a 64-bit executable on a 32-bit OS. Either install a 64-bit OS, or rebuild your compiler to produce 32-bit executables.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.