Deploying Source Code to Cygwin VM

1. Unpacking source code

Open Cygwin console, create directory /opt/crosstool/src (mkdir -p), and unpack binutils, gcc-core, gcc-g++, mpc, mpfr, gmp and glibc into it. Use "tar zxvf" to unpack .tar.gz files and "tar jxvf" to unpack .tar.bz2 files.

You should get the following folders:


Also you need to create the following folders:


and extract your Linux API headers into .../usr/include (for both i486 and x86_64 roots).

2. Preventing glibc build error on case-insensitive filesystem

glibc has a problem when built under Cygwin: it needs case-sensitive filesystem, otherwise .os and oS files collide and "make" phase of glibc build fails with the following error message:

.../build-glibc/elf/librtld.os: In function `process_envvars':
../glibc-2.10.1/elf/rtld.c:2718: undefined reference to `__open'
../glibc-2.10.1/elf/rtld.c:2690: undefined reference to `__access'
../build-glibc/elf/librtld.os: In function `dl_main':
../glibc-2.10.1/elf/rtld.c:1657: undefined reference to `__access'

In order to prevent this problem, in glibc source tree: find all makefiles containing ".oS" string (in that exact case) and replace it with ".oZ". Do not touch ".os" strings.

Here is a list of files to be updated for glibc-2.10.1:

3. Creating temporary folders for build

gcc and glibc, and probably other software and libraries will not build in their source folders. So, please create build-gmp, build-mpfr, build-mpc, build-binutils, build-gcc, build-glibc subfolders in C:\Cygwin\opt\crosstool\src. These subfolders will contain intermediary build results when corresponding software will be built.

4. Creating script files

Also please prepare stub batch file C:\Cygwin\opt\crosstool\src\build_gcc_cross.cmd with the following contents:

@echo off
set PATH=C:\Cygwin\bin;%PATH%
bash.exe -l -c /opt/crosstool/src/

Also please prepare main build script file C:\Cygwin\opt\crosstool\src\ with the following contents:


echo "=== build script: OK ==="

and apply Cygwin dos2unix tool to it in order to convert 0x0D,0x0A line endings (DOS/Windows format) to 0x0A line endings (UNIX format).

Then run build_gcc_cross.cmd to make sure scripts work as expected.

It's recommended to shutdown the virtual machine and make snapshot "SNAP-2" when initial deployment is done. Otherwise in case of any errors in future you'll have to start all this Rube Goldbergy again.

>> Read next section or buy already prepared cross-compiler ($10) to save your time.