Something for the FAQ - How do I cross compile...

Mumit Khan
Thu Aug 21 00:42:00 GMT 1997

root <> writes:
> If I want to build the Gnu-win32 so that I can produce NT programs
> under Linux or another host/build machine, what do I use for the
> --target entry?  i686-cygwin32-gnu says fcntl.h is missing, and I
> will try some other things, but it would really help if you would
> say somewhere in the faq how to do this.
> -

I remember a post by Geoffrey Noer a long time back with the essentials,
and I've successfully used that since b17 to build everything under
i386-linux. I'll use i386-linux instead of the more specific i[456] etc.

I do this regularly and haven't had any problems. Here's an excerpt
from a message that I had sent someone else (replace b17 with 18.1):

 -- using template mhl.format --

From:    Mumit Khan <>

You really need to start with getting the whole source tree for cygnus
gnu-win32 b17.1 from cygnus's ftp site. You of course do need a C compiler
already installed on your machine (eg., gcc) to bootstrap the cross
compiler. GCC 2.7.2* work quite well when building the cross compiler.

You don't need the source for gcc other than what comes with gnu-win32
source distribution (there is gcc in there already, as well as a whole
bunch of other things).

Here's what I've done:

Part 1: Building the cross-compiler 

1. Get Cygnus b17.1 source tree for the compiler toolchain*

   Comes as a bunch of files xaa, xab, etc.

2. Unzip and untar on your Unix machine (say a Linux machine). Let's
   assume you untar everything under $srcdir (where $srcdir in my
   case is /src/gnu/gnu-win32-b17.1)

   % mkdir gnu-win32-b17.1
   % cd gnu-win32-b17.1
   % cat ../xa* | tar zxvf -

3. Now create a build tree.

   % mkdir cross-build
   % cd cross-build

4. Configure for cross compiler
   % $srcdir/configure --target=i386-cygwin32 --host=i386-linux \
     -v --prefix=/scratch/gnu

   Replace /scratch/gnu above with what you want. This is where the 
   cross-compilers will eventually end up!

5. Make the cross-compiler now
   % make >& make.log
   % make install

Part 2: [OPTIONAL] Building the native tools

1. Add $prefix/bin to your path <<<<<<<< Make sure you do this!

2. Create a new build tree

   % mkdir cygwin32
   % cd cygwin32

3. Configure for native tools
   % $srcdir/configure --prefix=/scratch/gnu-win32 \
     --exec-prefix=/scratch/gnu-win32/H-i386-cygwin32 \
     --target=i386-cygwin32 --host=i386-cygwin32 \
     --build=i386-linux -v

4. ``make'' and ``make install''

Part 3: [OPTIONAL] Build native user tools.

[... same as Part 2 ... ]


Mumit --
For help on using this list (especially unsubscribing), send a message to
"" with one line of text: "help".

More information about the Cygwin mailing list