Cygwin/X Contributor's Guide
Prev | Appendix A. Building a cross-compiler | Next

# Obtaining Cygwin headers and libraries

The usual technique for building GCC cross-compilers is to:

1. build binutils

2. build a bootstrap compiler (--without-headers --enable-languages=c) that will only be used to build the C runtime library.

3. use the bootstrap compiler to build the C runtime library.

4. rebuild the final compiler, including internal libraries that need the target-specific C runtime library in order to be compiled properly.

Unfortunately, this technique cannot be applied building a cross-compiler for Cygwin, not least due to the use of C++ code in `winsup/`.

The simplest method of escaping from this chicken-and-egg situation is to make the Cygwin headers and libraries available at the time of building the cross-compiler, by installing them from the Cygwin binary packages containing those headers and libraries.

Headers and libraries from the following packages are required:

- cygwin (needed for building libgcc)

- win32api (needed for building libgcc)

- iconv (needed for building libstdc++)

    user@crosshost ~/cygwin/src $ wget $YOUR_MIRROR/release/cygwin/cygwin-1.7.7-1.tar.bz2
    user@crosshost ~/cygwin/src $ wget $YOUR_MIRROR/release/w32api/w32api-3.15-1.tar.bz2
    user@crosshost ~/cygwin/src $ wget $YOUR_MIRROR/release/libiconv/libiconv-1.13-10.tar.bz2
    user@crosshost ~/cygwin/src $ cd ~/cygwin
    user@crosshost ~/cygwin $ tar xjf src/cygwin-1.7.7-1.tar.bz2 usr/include usr/lib
    user@crosshost ~/cygwin $ tar xjf src/w32api-3.15-1.tar.bz2 usr/include usr/lib
    user@crosshost ~/cygwin $ tar xjf src/libiconv-1.13-10.tar.bz2 usr/include usr/lib
    user@crosshost ~/cygwin $ ln -s ../usr/include/ i686-pc-cygwin/include
    user@crosshost ~/cygwin $ ln -s ../usr/lib/ i686-pc-cygwin/lib

Alternatively, these headers and libraries can be obtained by copying the contents of the `/usr/lib` directory and `/usr/include` directory of a Cygwin host, to the `~/cygwin/i686-pc-cygwin` directory on your build host. Ensure the method you use to copy these files preserves symlinks.

Prev | Home | Next
Building a cross-compiler | Up | Building binutils