Compiling gcc as cross-compiler

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
mbg
Posts: 2
Joined: Tue Jun 02, 2009 4:55 am

Compiling gcc as cross-compiler

Post 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
mbg
Posts: 2
Joined: Tue Jun 02, 2009 4:55 am

Re: Compiling gcc as cross-compiler

Post 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.
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: Compiling gcc as cross-compiler

Post 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.
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Compiling gcc as cross-compiler

Post 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.
Every good solution is obvious once you've found it.
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: Compiling gcc as cross-compiler

Post 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.
gedd
Member
Member
Posts: 104
Joined: Thu Apr 10, 2008 1:47 am

Re: Compiling gcc as cross-compiler

Post 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
[ Grub 2 | Visual Studio 2013 | PE File ]
The OsDev E.T.
Don't send OsDev MIB !
Post Reply