Fedora Linux Support Community & Resources Center
  #1  
Old 13th February 2008, 08:30 PM
early-ehlinger Offline
Registered User
 
Join Date: Feb 2008
Posts: 24
gcc cross compiler for target i386-pc-mingw32

So I've decided to try getting my hands dirty at building a gcc cross compiler targeting i386-pc-mingw32. Why? Two reasons:

1: I'm really starting to like developing on Linux.
2: I'm really starting to dislike developing on Windows.

However, I do still need to produce Windows EXE's and DLL's, so if I'm to begin developing exclusively on Linux, I need a gcc -b i386-pc-mingw32.

So, I'm going to see if I can get a cross compiler up & running, and log my efforts here. I'm not there yet. Hopefully this thread can eventually serve as an impetus for three things:

1) Making it easier for others to do the same if they so desire.
2) Give others the opportunity to help me if they have been through this before. I googled my heart out, but I can't seem to find specific instructions for Fedora 8 + GCC 4.1.2
3) It would be really cool if you could just go to Package Manager, and tell Fedora to download and install a cross-compiler for some target. Obviously, I'm interested in i386-pc-mingw32, but others may want other targets too. Having such a capability would IMHO make Linux (esp Fedora) even more attractive as a development platform.

I'm using http://vmlinux.org/crash/mirror/www....GCC/FAQ-4.html as a basic guide, although it appears that parts are out of sync with reality :-(

First, I created a directory called ~/Projects/gcc-4.1.2-mingw/, since I'm trying to build gcc 4.1.2 (to match Fedora 8's gcc version).

I then downloaded binutils-2.18.tar.bz2. It looks like Fedora8 comes with 2.17.5, but I couldn't find that in the GCC mirrors, so I went with the next version up, 2.18. I then decompressed it, configured, and built it:

$ tar -xjvf binutils-2.18.tar.bz2
$ cd binutils-2.18
$ ./configure --target=i386-pc-mingw32 --prefix=~/Projects/gcc-4.1.2-mingw/bin -v
$ make all
$ make install

I was a bit nervous doing the "make install" bit, because I was concerned it would install these binutils into the main GCC installation. That will be fine once I'm confident I know what I'm doing, but for now, caution is the word of the day.

Luckily, this put the binutil files under ~/Projects/gcc-4.1.2-mingw/bin/bin/, 1 level deeper than I would've liked, but it's good enough.

Next post: building GCC itself.
Reply With Quote
  #2  
Old 13th February 2008, 08:35 PM
early-ehlinger Offline
Registered User
 
Join Date: Feb 2008
Posts: 24
As I previously posted, I'm using this thread as a blog of sorts to track my experience with building a GCC cross compiler for the target i386-pc-mingw32.

So far, I've built binutils-2.18 successfully. The next step is gcc-4.1.2:

$ tar -xjvf gcc-4.1.2.tar.bz2
$ cd gcc-4.1.2
$ ./configure --target=i386-pc-mingw32 --prefix=~/Projects/gcc-4.1.2-mingw/bin
$ make

Unfortunately, I get this error at this point:

Code:
WARNING: `makeinfo' is missing on your system.  You should only need it if
         you modified a `.texi' or `.texinfo' file, or any other file
         indirectly affecting the aspect of the manual.  The spurious
         call might also be the consequence of using a buggy `make' (AIX,
         DU, IRIX).  You might want to install the `Texinfo' package or
         the `GNU make' package.  Grab either from any GNU archive site.
make[3]: *** [fastjar.info] Error 1
make[3]: Leaving directory `~/Projects/gcc-4.1.2-mingw/gcc-4.1.2/host-x86_64-unknown-linux-gnu/fastjar'
make[2]: *** [all] Error 2
make[2]: Leaving directory `~/Projects/gcc-4.1.2-mingw/gcc-4.1.2/host-x86_64-unknown-linux-gnu/fastjar'
make[1]: *** [all-fastjar] Error 2
make[1]: Leaving directory `~/Projects/gcc-4.1.2-mingw/gcc-4.1.2'
make: *** [all] Error 2
Reply With Quote
  #3  
Old 13th February 2008, 08:37 PM
early-ehlinger Offline
Registered User
 
Join Date: Feb 2008
Posts: 24
Here's a very frustrating aspect of this error:
Code:
$ makeinfo --version
makeinfo (GNU texinfo) 4.11

Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reply With Quote
  #4  
Old 13th February 2008, 08:45 PM
early-ehlinger Offline
Registered User
 
Join Date: Feb 2008
Posts: 24
I did a quick hack to see if I could fix this:

Code:
$ cd host-x86_64-unknown-linux-gnu/fastjar
$ which makeinfo
/usr/bin/makeinfo
$ gedit Makefile &
I then found the line that looked something like this:

Code:
MAKEINFO = ~/Projects/gcc-4.1.2-mingw/gcc-4.1.2/missing makeinfo --split-size=5000000
And replaced it with:

Code:
MAKEINFO = /usr/bin/makeinfo --split-size=5000000
Save, exit, back to xterm:

Code:
$ cd ../../
$ make all
It's still compiling as I write this. Next post - if this compiles, playing with gcc. If not, more troubleshooting.
Reply With Quote
  #5  
Old 13th February 2008, 08:54 PM
early-ehlinger Offline
Registered User
 
Join Date: Feb 2008
Posts: 24
Quote:
Originally Posted by early-ehlinger
It's still compiling as I write this. Next post - if this compiles, playing with gcc. If not, more troubleshooting.
Looks like more troubleshooting.

Here's the error:

Code:
~/Projects/gcc-4.1.2-mingw/gcc-4.1.2/host-x86_64-unknown-linux-gnu/gcc/xgcc -B~/Projects/gcc-4.1.2-mingw/gcc-4.1.2/host-x86_64-unknown-linux-gnu/gcc/ -B~/Projects/gcc-4.1.2-mingw/bin/i386-pc-mingw32/bin/ -B~/Projects/gcc-4.1.2-mingw/bin/i386-pc-mingw32/lib/ -isystem ~/Projects/gcc-4.1.2-mingw/bin/i386-pc-mingw32/include -isystem ~/Projects/gcc-4.1.2-mingw/bin/i386-pc-mingw32/sys-include -O2 -I../.././gcc/../winsup/w32api/include -O2 -g -O2  -DIN_GCC -DCROSS_COMPILE   -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -Dinhibit_libc -I. -I. -I../.././gcc -I../.././gcc/. -I../.././gcc/../include -I../.././gcc/../libcpp/include  -DL_muldi3 -c ../.././gcc/libgcc2.c -o libgcc/./_muldi3.o
In file included from ./tm.h:10,
                 from ../.././gcc/libgcc2.c:35:
../.././gcc/config/i386/cygming.h:52:19: error: stdio.h: No such file or directory
In file included from ./tm.h:10,
                 from ../.././gcc/libgcc2.c:35:
../.././gcc/config/i386/cygming.h:333: error: expected ‘)’ before ‘*’ token
It looks like for some reason stdio.h isn't on the -I path. I'm going to have to hunt it down and/or fix the dang Makefile to get gcc to find it. Aggh.
Reply With Quote
  #6  
Old 13th February 2008, 09:17 PM
early-ehlinger Offline
Registered User
 
Join Date: Feb 2008
Posts: 24
Code:
$ find . -name stdio.h
./fixincludes/tests/base/stdio.h
./libstdc++-v3/include/c_compatibility/stdio.h
./libssp/ssp/stdio.h
./gcc/testsuite/gcc.dg/cpp/usr/include/stdio.h
Not sure which one to use, so I'm just going to run with ./libstdc++-v3/include/c_compatibility/stdio.h and switch it up if things don't work :-)

Code:
$ gedit host-x86_64-unknown-linux-gnu/gcc/Makefile &
I then looked for a -I line to hack. Found this:

Code:
INCLUDES = -I. -I$(@D) -I$(srcdir) -I$(srcdir)/$(@D) \
	   -I$(srcdir)/../include  \
	   $(CPPINC) $(GMPINC)
And turned it into this:

Code:
INCLUDES = -I. -I$(@D) -I$(srcdir) -I$(srcdir)/$(@D) \
	   -I$(srcdir)/../include  -I$(srcdir)/../libstdc++-v3/include/c_compatibility/ \
	   $(CPPINC) $(GMPINC)
Didn't help.

Code:
INCLUDES = -I. -I$(@D) -I$(srcdir) -I$(srcdir)/$(@D) \
	   -I$(srcdir)/../include  \
	   $(CPPINC) $(GMPINC) \
	   -I$(srcdir)/../libstdc++-v3/include/c_compatibility/
Likewise didn't help. Both simply turned the one error into a pile of errors. Perhaps libstdc++-v3 isn't the right one to make gcc happy.

Tried similar with all locations returned from find, with no joy. Argh.

Last edited by early-ehlinger; 13th February 2008 at 09:25 PM.
Reply With Quote
  #7  
Old 13th February 2008, 09:36 PM
early-ehlinger Offline
Registered User
 
Join Date: Feb 2008
Posts: 24
Trying a different tack.

I created a directory inside gcc-4.1.2 called "hack"

I then tried
Code:
cp fixincludes/tests/base/stdio.h hack/
And changed the makefile to include the hack directory.

Also tried with all 4 copies of stdio.h in the gcc-4.1.2 directory.

No joy yet.
Reply With Quote
  #8  
Old 13th February 2008, 09:43 PM
early-ehlinger Offline
Registered User
 
Join Date: Feb 2008
Posts: 24
Tried an absolutely crazy option. Changed the makefile to use the *SYSTEM* include directory, /usr/include.

This doesn't get me completely there, but it does give me some alternative errors. Notably:

Code:
../.././gcc/config/i386/gthr-win32.c:34:21: error: windows.h: No such file or directory
In file included from ../.././gcc/config/i386/gthr-win32.c:40:
../.././gcc/gthr-win32.h:70:20: error: _mingw.h: No such file or directory
This suggests that now the mingw headers are missing, which is (I hope) a step in the right direction.
Reply With Quote
  #9  
Old 14th February 2008, 09:10 PM
early-ehlinger Offline
Registered User
 
Join Date: Feb 2008
Posts: 24
Let's see if I can make up a Dr. Phil-style saying...

Well grab an idiot cap and slap it on my head, 'cuz I was acting like a fool dog barkin' up a tree instead of diggin' in the dirt.

So it turns out that one of the mingw packages contains a nice script that automates the build process for a hosted cross compiler. Unfortunately, it builds v3.4.5 of GCC, but it works, so that's a step in the right direction.

The name of the package to download is "Cross-Hosted MinGW Build Tool," and it's available here: http://sourceforge.net/project/showf...?group_id=2435 If you're trying to do this, you need the full tarball, *not* the source tarball. Once you download it, run x86-mingw32-build.sh

It's pretty close to exactly what I needed, although it could stand to be updated to use v4.x of GCC. Still, a very impressive little script that instantly killed all of the (probably stupid) mistakes I was making.
Reply With Quote
Reply

Tags
compiler, cross, gcc, i386pcmingw32, target

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cross compile (mingw32) link error RedFedora Programming & Packaging 0 6th September 2009 06:44 PM
Windows Cross Compiler corneliu Alpha, Beta & Snapshots Discussions (Fedora 11 Only) 7 7th February 2009 02:40 PM
Cross compiler for ARM fixyou Programming & Packaging 7 24th January 2008 04:20 PM
Cross compiler for ARM fixyou Using Fedora 4 24th January 2008 10:33 AM


Current GMT-time: 05:32 (Friday, 18-04-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat