My goal is to cross compile on Cygwin (on Winderz) for a Linux target – both 64 bit Ubuntu 13.10 or an ARM (such as a Beagle Bone). I sadistically thought that this could be done in MinGW. Two words: Um, oops.
The real purpose is to take a Windows GUI that generates C code and compile it for a different platform (hence cross compiling). These are my steps which are based on this guy’s post.
Note that as information on the web becomes quickly out of date, realize that this is the end of March in 2014.
- Before you begin, it is imperative to set your file system to be case sensitive in Windows. Both the kernel headers and C library use file names with the same case insensitive name but different case sensitive name. Open regedit.exe and set the following to 0.
- Download and Cygwin from here. We will assume that you installed it on C:\cygwin. I am using the Cygwin 2.844 32 bit version as the compiler being built because it will run on 32 bit or 64 bit Windows.
- When you run setup, you will get a nice GUI to choose your packages. If you ever want to add or remove a package, you run setup again (seems counter-intuitive on Windows). Take the defaults and add the following packages (not all may be required but it didn’t hurt).
- Devel/make: The GNU version…
c:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico -
wget http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.19.0.tar.bz2 tar xjf crosstool-ng-1.19.0.tar.bz2 cd crosstool-ng-1.19.0 ./bootstrap ./configure --prefix=/home/maks/crosstool
make make install
mkdir /usr/include/linux cp /usr/include/asm/types.h /usr/include/linux
Then edit /usr/include/linux/types.h and include the following:
typedef __signed__ long long __s64; typedef unsigned long long __u64;
mkdir ~/src mkdir ~/linux64 cd ~/linux64 ct-ng i686-nptl-linux-gnu ct-ng menuconfig
ct-ng list-steps ct-ng <last successful step name>+
So that is that. I compiled a C and C++ program on Windows and ran the binaries on Linux 64 bit Ubuntu 13.10.