Search code examples
gccmipstoolchain

bash: ./mips-linux-gnu-gcc: cannot execute binary file error


I've recently installed a mips-linux-gnu-gcc crosstool in my linux machine which is based on i686. When I want to compile some codes, it showed me that error.

Every installing step was followed by http://developer.mips.com/tools/compilers/open-source-toolchain-linux/

After I installed the crosstool, I wrote a simple helloworld C file like this:

    #include<stdio.h>
    int main(void)
    {
        printf("Hello World!\n");
        return 0;
    }

But when I run:

    /mips-linux-gnu-gcc hello.c -o hello -static

The compiler just print error:

    bash: ./mips-linux-gnu-gcc: cannot execute binary file

I'm wondering maybe I've made some mistakes in some steps, but I can't figure it out.

Maybe some of you can help me, I'm confused by the problem.


Solution

  • The compiler you downloaded from MIPS is a 64-bit executable. Are you running a 32-bit host?

    If you need a cross compiler for a 32-bit host targeting MIPS GNU/Linux, consider using the Sourcery CodeBench Lite compiler for MIPS GNU/Linux targets:

    Sourcery CodeBench Lite for MIPS GNU/Linux

    The link to the Sourcery CodeBench tools above comes from the MIPS pages just one level up from the link you provided:

    MIPS Compilers Page