What is cross compiling? Most programs are compiled to machine code, that can only be executed by machines of the same type. When a windows computer compiles code into a program, only windows computer can run it. When a Macintosh computer compiles code into a program, only a Macintosh computer can run it. The scripts I make available here are for making Cross compilers, so that a Macintosh can compile code into a program that runs on a Windows computer instead. This is were the more laymen explanations end, if you would like to learn more about a cross compiler, see here. This article does assume a basic understanding of commonly used terminal commands, and general programing knowledge.

On this page I will host scripts I have written for creating cross compilers. This is work done in my free time, so progress will be slow. Hopefully, I will eventually host cross compilers that target Linux, Windows, and Macintosh. Each script is meant to be run on a specific host (ie: Linux x86) and create a cross compiler for a specific target (ie: Windows x86).

Cross compilers are complicated, so there may be bugs in these scripts or the produced executable that I am not aware of. These scripts, nor there results, come with any warranty, and are available under the GPL.

Each script will build the GNU C, C++, Fortran, Java, and objective-C/objective-C++ cross compilers. If you would like to exclude one or more of them, remove them from the script. If you would like additional compilers, such as the Pascal or D compiler, you will need to add that functionality to the script yourself.

When running the scripts, you can additionally specify a different version of GCC to used, or even different package versions for the other needed programs.

These scripts are meant to be run by a user without root privalges, and default to installing in the home folder. If you want to install to a different location, such as /usr/local/ so that the binaries are in your path, you will need to run the script as root and specify that location when prompted. Or you can create symbolic links to the executables yourself, which I recommend over the other option, as I have not tested installing to those locations.

 

Target: x86 Windows

Download

This script has been written for Linux x86 & x64, and Intel Macs; it uses the MinGW project to help create the cross compiler. You will be prompted with the option to either download the binaries, or source code. Some versions of GCC do not like compiling the source code for MinGW, however they will work if you download binaries instead of source. Note: GCC 4.1.X has significant trouble creating a cross compiler for Windows, you probably want to avoid that version. The default is GCC 4.2.4, which works completely.

General: Should the script fail, you will need to delete the folders it created. There will be folders in the same directory the script is, and a folder were the cross compiler was to be installed. If you have difficulty running the script, make sure you have installed the needed prerequisites. For versions of GCC other than 4.2.4, specifying the use of binaries instead of source code for MinGW can help. If the computer building the cross compiler is slow, you may want to specify downloading binaries simply to save time.

Linux (x86 & x64): You need to have bison, flex, sed, gcc, g++ and a few other tools installed. Run this command to make sure you have the prerequisites.
Debain/Ubuntu:sudo apt-get install bison flex sed gcc g++ build-essential expect gnat texinfo

OS X, Intel: You need to install Xcode and the developer tools, it is one download available from Apple. The other prerequisites will be downloaded and installed for you by the script, just read the prompts.

OS X, PowerPC & Other platforms: I simply do not have the machines to test this on, if you would like to port any of my scripts, or can confirm that they work with the proper HOST setting, please let me know!