문제

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.

도움이 되었습니까?

해결책

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

다른 팁

It looks like the mips-linux-gnu-gcc binary does not match the architecture of the machine you are trying to run it on. This might be something like a 32/64 bit mismatch.

Try using the free Mentor/Codesourcery MIPS gnu/gcc cross compilation tool chain instead. You can download from here.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top