Page 1 of 1

Compiling gcc as cross-compiler

Posted: Tue Jun 02, 2009 5:04 am
by mbg
Hi

I have followed the tutorial in the wiki to build a cross-compiler version of gcc. I was able to build and install gmp, mpfr and binutils. However, every time I try to build gcc, I get the following error:

Image

As you can see I am running cygwin / Windows Vista on this machine (64-bit). The gcc package is version 4.4.0, binutils 2.19.1, gmp 4.3.1 and mpfr 2.4.1.

Any suggestions on what the cause of this error might be and how to resolve the issue? Thanks in advance.

mbg

Re: Compiling gcc as cross-compiler

Posted: Tue Jun 02, 2009 9:37 am
by mbg
Also, when I try to compile the cross-compiler on Mac OS X, I encounter problems with gmp and mpfr:

libgmp.dylib, file is not of the required architecture
libmpfr.dylib, file is not of the required architecture

After some googling, I tried adding the --host switch when configuring the build for them. However, that made no difference and it still complains while configuring gcc. Then I tried compiling them at the same time as gcc by moving the gmp and mpfr source folders into the gcc source folder. It started compiling, obviously, but ended up with the same problem as before.

Any help would be appreciated.

EDIT: Managed to fix the issue on Mac OS X by deleting all the build-xxx folders and all files that were generated in /usr/local and then rebuilding everything again using the additional --host/--build switches.

Re: Compiling gcc as cross-compiler

Posted: Wed Jun 03, 2009 1:17 am
by xenos
I remember having a similar problem compiling GCC on a windows machine... It is caused by the "sort" command. When compiling, a program named "sort" is needed, and since there is no path specified, it searches along the path(s) given in the PATH environment variable. Finally, it finds the Windows sort utility in some Windows directory, runs it - and crashes, since this one doesn't know about a command line switch named "-u". Instead, the "sort" program provided with CygWin has to be used. To do this, you can change the PATH variable, such that the directory containing your CygWin binaries occurs before any Windows directories.

Re: Compiling gcc as cross-compiler

Posted: Wed Jun 03, 2009 1:40 am
by Solar
I haven't tried Windows Vista so far, but on my machines a Cygwin Bash Shell prompt looks like this:

Code: Select all

<User>@<Hostname> ~ $
Yours reads:

Code: Select all

sh-3.2$
That is why I suspect you are not running the Cygwin Bash Shell (the one you get an icon on the desktop and in the Start menu for by the Cygwin installer) but... I don't know, a Windows cmd.exe in which you started sh, or something? The Cygwin shell automatically sets the PATH variable as required.

Re: Compiling gcc as cross-compiler

Posted: Wed Jun 03, 2009 1:49 am
by pcmattman
My suggestion would be to run the Cygwin installer in compatibility mode for XP SP2, and ensure that you run as administrator.

I've run into the same thing (and similar effects on other programs, not just Cygwin) on Windows 7. In my case there was a whole lot missing from the Cygwin install directories (for example, <cygwin-root>/etc/skel, amongst many others), which eventually meant that it was not mounting directories properly, which caused things like bash to run incorrectly.

Re: Compiling gcc as cross-compiler

Posted: Wed Jun 03, 2009 2:06 am
by gedd
I have compiled Cross-GCC many time on Vista or XP with Osdev Cross compiler tutorial, it works perfectly
Just follow the tutorial in details and
- check the table "Tested on... ", don't try not tested combinaison
- launch cygwin not administrator console