Cygwin: Cross compiler: cc1.exe "cannot execute binary file"
Cygwin: Cross compiler: cc1.exe "cannot execute binary file"
I'm trying to get my cross compiler to work. I've done it before, but I lost my Cygwin installation so I have to do it over.
Some details:
Cygwin
Binutils 2.21
GCC 4.6.0
I'm following the GCC Cross-Compiler wiki page, and everything compiles fine. However, when I execute i586-elf-g++.exe with some arbitrary .c or .cpp file, I get the error:
i586-elf-g++: error: spawn: Exec format error
So, I cd to /usr/local/cross/bin and execute all of the executables without any parameter. Most succeed, except with i586-elf-cpp.exe I get the same 'Exec format error' message. I assume g++.exe executes cpp.exe, but I'm not familiar with GCC internals.
Next, I ran the cpp.exe under gdb, and found that before printing the error, it calls 'pex_run', with argument '/usr/local/cross/libexec/gcc/i586-elf/4.6.0/cc1.exe'
When I try to run this cc1.exe manually, I get 'bash: ./cc1.exe: cannot execute binary file'. I tried to recompiler gcc, but the problem persists.
$ file cc1.exe
cc1.exe: PE32 executable (console) Intel 80386, for MS Windows
Which is exactly the same as any other .exe.
The only other file in '/usr/local/cross/libexec/gcc/i586-elf/4.6.0/' that has the same problem is cc1plus.exe. Other .exe files, like 'collect2.exe' work fine.
I'm not really sure how I can approach this, as most of the gcc binaries seem to work fine, why would cc1.exe be any different?
Right now, I'm re-building gcc again while piping the output to a file so I can see if there are any warnings when compiling cc1, but I thought as I'd ask here already as I don't think it will result in anything.
Thanks in advance for any input
Edit:
I see now that during make all, I also get a 'format Error', this time from 'xgcc'... make just keeps going though, it does not stop with an error.
In command:
/usr/src/build-gcc/./gcc/xgcc -B/usr/src/build-gcc/./gcc/ -E -dM -
Some details:
Cygwin
Binutils 2.21
GCC 4.6.0
I'm following the GCC Cross-Compiler wiki page, and everything compiles fine. However, when I execute i586-elf-g++.exe with some arbitrary .c or .cpp file, I get the error:
i586-elf-g++: error: spawn: Exec format error
So, I cd to /usr/local/cross/bin and execute all of the executables without any parameter. Most succeed, except with i586-elf-cpp.exe I get the same 'Exec format error' message. I assume g++.exe executes cpp.exe, but I'm not familiar with GCC internals.
Next, I ran the cpp.exe under gdb, and found that before printing the error, it calls 'pex_run', with argument '/usr/local/cross/libexec/gcc/i586-elf/4.6.0/cc1.exe'
When I try to run this cc1.exe manually, I get 'bash: ./cc1.exe: cannot execute binary file'. I tried to recompiler gcc, but the problem persists.
$ file cc1.exe
cc1.exe: PE32 executable (console) Intel 80386, for MS Windows
Which is exactly the same as any other .exe.
The only other file in '/usr/local/cross/libexec/gcc/i586-elf/4.6.0/' that has the same problem is cc1plus.exe. Other .exe files, like 'collect2.exe' work fine.
I'm not really sure how I can approach this, as most of the gcc binaries seem to work fine, why would cc1.exe be any different?
Right now, I'm re-building gcc again while piping the output to a file so I can see if there are any warnings when compiling cc1, but I thought as I'd ask here already as I don't think it will result in anything.
Thanks in advance for any input
Edit:
I see now that during make all, I also get a 'format Error', this time from 'xgcc'... make just keeps going though, it does not stop with an error.
In command:
/usr/src/build-gcc/./gcc/xgcc -B/usr/src/build-gcc/./gcc/ -E -dM -
Re: Cygwin: Cross compiler: cc1.exe "cannot execute binary f
No one?
Is my question/problem unclear, or does no one, like me, have a clue how to tackle this?
Is my question/problem unclear, or does no one, like me, have a clue how to tackle this?
Re: Cygwin: Cross compiler: cc1.exe "cannot execute binary f
As you're using gcc 4.6.0, do you have the necessary other libraries (libgmp-devel, libmpfr-devel, and libmpc-devel)? Also, I'd try building GCC 4.5.2, as I have had success building that and g++ on cygwin.
Wait... What?
Re: Cygwin: Cross compiler: cc1.exe "cannot execute binary f
Thank you for your reply.
I do have all the necessary libs (else configure would fail probably). Configure does complain that some headers, belonging to those libs, are 'buggy but acceptable'.
I tried 4.5.2 with exactly the same problem:
i586-elf-g++: error trying to exec '/usr/local/cross/libexec/gcc/i586-elf/4.5.2/cc1plus.exe': execv: Exec format error
So now it executes cc1plus.exe instead of cc1.exe.
I used the same binutils tough, will try an older version of that later today.
I do have all the necessary libs (else configure would fail probably). Configure does complain that some headers, belonging to those libs, are 'buggy but acceptable'.
I tried 4.5.2 with exactly the same problem:
i586-elf-g++: error trying to exec '/usr/local/cross/libexec/gcc/i586-elf/4.5.2/cc1plus.exe': execv: Exec format error
So now it executes cc1plus.exe instead of cc1.exe.
I used the same binutils tough, will try an older version of that later today.
Re: Cygwin: Cross compiler: cc1.exe "cannot execute binary f
Check out Cross-Compiler Successful Builds. According to that matrix, you shouldn't have problems with your versions.
Fanael successfully build a 4.5.2 / 2.21, Dajoh a 4.6.0 / 2.21. Chances are that either your setup or your procedure is broken.
Fanael successfully build a 4.5.2 / 2.21, Dajoh a 4.6.0 / 2.21. Chances are that either your setup or your procedure is broken.
Every good solution is obvious once you've found it.
Re: Cygwin: Cross compiler: cc1.exe "cannot execute binary f
Hi,
I have a successful 4.6.0 / 2.2.1 (i686-elf) build. Your cross-compiler setup could be broken, but with the Exec error, could it be that it's actually your Cygwin install that's broken? Also, are you using the 1.7.x version of Cygwin?
One other thing to check - is your PATH environment variable correctly set (i.e. it contains all the default locations Cygwin adds for you, plus the location of your cross compiler binaries)?
Cheers,
Adam
I have a successful 4.6.0 / 2.2.1 (i686-elf) build. Your cross-compiler setup could be broken, but with the Exec error, could it be that it's actually your Cygwin install that's broken? Also, are you using the 1.7.x version of Cygwin?
One other thing to check - is your PATH environment variable correctly set (i.e. it contains all the default locations Cygwin adds for you, plus the location of your cross compiler binaries)?
Cheers,
Adam
Re: Cygwin: Cross compiler: cc1.exe "cannot execute binary f
Hi,
I did I encounter this problem when I first started my OS(a year ago). I was able to resolve this by simply including the "X:\Cygwin\bin"(where X denote the Cygwin installation drive) to my path variable. It didn't even cost me a minute to resolve this so, I hope you too will dig your way out(just a matter of seconds).
Good Luck!
Edit: Wait a minute... I think I missed something. My case was a little bit different. After successful Cross Compilation, there wasn't anything named cc1.exe in the 'usr/local/cross/bin' directory. I had to manually copy this executable somewhere from the build directory. Is this the same case with you?
I did I encounter this problem when I first started my OS(a year ago). I was able to resolve this by simply including the "X:\Cygwin\bin"(where X denote the Cygwin installation drive) to my path variable. It didn't even cost me a minute to resolve this so, I hope you too will dig your way out(just a matter of seconds).
Good Luck!
Edit: Wait a minute... I think I missed something. My case was a little bit different. After successful Cross Compilation, there wasn't anything named cc1.exe in the 'usr/local/cross/bin' directory. I had to manually copy this executable somewhere from the build directory. Is this the same case with you?
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
Re: Cygwin: Cross compiler: cc1.exe "cannot execute binary f
If such a measure were necessary, that would not even be a broken cross-compiler tutorial, but a broken GCC release.
Which is not completely improbable, seeing how it's a *.0 release.
Which is not completely improbable, seeing how it's a *.0 release.
Every good solution is obvious once you've found it.
Re: Cygwin: Cross compiler: cc1.exe "cannot execute binary f
It shouldn't be necessary. I compiled 4.6.0/2.21 yesterday on and old installation of Cygwin 1.7 (Windows Vista) and it seemed to work out of the box.Solar wrote:If such a measure were necessary, that would not even be a broken cross-compiler tutorial, but a broken GCC release.
Cheers,
Adam
Re: Cygwin: Cross compiler: cc1.exe "cannot execute binary f
Thank you all for your replies.
>One other thing to check - is your PATH environment variable correctly set (i.e. it contains all the default locations Cygwin adds for you, plus the location of your cross compiler binaries)?
Yes it is
I suspect that my Cygwin installation is borked... Thank you all for your help, I'll re-install and try again.
EDIT:
I decided to compile in a Linux VM... everything works fine there
>One other thing to check - is your PATH environment variable correctly set (i.e. it contains all the default locations Cygwin adds for you, plus the location of your cross compiler binaries)?
Yes it is
I suspect that my Cygwin installation is borked... Thank you all for your help, I'll re-install and try again.
EDIT:
I decided to compile in a Linux VM... everything works fine there