This is an old revision of the document!
Setting up the build environment on Windows
Assuming Windows XP 32. We will use MinGW to build the libraries and application and MSYS as a working environment.
The distinction between MinGW and MSYS is very important: MinGW is a set of compilers and libraries you use to build Windows applications, while MSYS is a GNU environment similar to (and, in fact, based on) Cygwin. You can not
use MSYS libraries in your Windows application.
Subversion
Doesn't really matter which one. Certified binaries of The Real McCoy are available at http://www.collab.net/downloads/subversion/ (command-line only) if you have an account (or are willing to register). There are other (non-certified) sources such as SlikSVN (http://www.sliksvn.com/en/download, command-line only) and TortoiseSVN (http://tortoisesvn.net/downloads, with Windows Explorer integration, which is really neat).
MSYS
Download the MSYS Base System installer from http://downloads.sourceforge.net/project/mingw/MSYS%20Base%20System/msys-1.0.11/MSYS-1.0.11.exe and run it. If it asks, tell it you don't have MinGW installed.
Now that MSYS is installed, you can start the “MSYS (rxvt)” shortcut it installed, and it'll be almost like you were home on the Unix farm.
MinGW
As of November 2009, the automated installer is useless; it installs gcc 3 instead of 4. You'll have to install MinGW manually using MSYS.
The following command will create and mount a directory for MinGW:
mount C:/MinGW /mingw
Next, download the packages you will need.
Then extract everything:
$ for f in *tar.gz ; do tar zxvf $f -C /mingw ; done $ for f in *tar.lzma ; do tar --lzma -xvf $f -C /mingw ; done
Let's see if our C compiler works:
$ which gcc /mingw/bin/gcc.exe $ cat >hello.c #include <stdio.h> int main(void) { printf("Hello, C world!\n"); return 0; } ^D $ gcc -o hello hello.c $ ./hello.exe Hello, C world!
And C++:
$ which g++ /mingw/bin/g++.exe $ cat >hello.cc #include <iostream> int main() { std::cout << "Hello, C++ world!" << std::endl; return 0; } ^D $ g++ -o hello hello.cc $ ./hello.exe Hello, C++ world!
And Fortran 90:
$ which gfortran /mingw/bin/gfortran.exe $ cat >hello.f90 PROGRAM HelloWorld PRINT *, "Hello, Fortran world!" END PROGRAM HelloWorld ^D $ gfortran -o hello hello.f90 $ ./hello.exe Hello, Fortran world!
Perl
The GNU Autotools, which we will install next, require Perl. Download http://downloads.sourceforge.net/project/mingw/MSYS%20perl/perl-5.6.1_2-1/perl-5.6.1_2-1-msys-1.0.11-bin.tar.lzma and install it:
$ tar --lzma -xvf perl-5.6.1_2-1-msys-1.0.11-bin.tar.lzma -C /
GNU Autotools
Download
Autoconf
http://downloads.sourceforge.net/project/mingw/MinGW%20autoconf/autoconf2.5/autoconf2.5-2.64-1/autoconf2.5-2.64-1-mingw32-bin.tar.lzma and http://downloads.sourceforge.net/project/mingw/MinGW%20autoconf/wrapper/autoconf-7-1/autoconf-7-1-mingw32-bin.tar.lzma
Automake
http://downloads.sourceforge.net/project/mingw/MinGW%20automake/automake1.11/automake1.11-1.11-1/automake1.11-1.11-1-mingw32-bin.tar.lzma and http://downloads.sourceforge.net/project/mingw/MinGW%20automake/wrapper/automake-4-1/automake-4-1-mingw32-bin.tar.lzma
It generally pays to have older versions around, too; you can safely install e.g. 1.10 (http://downloads.sourceforge.net/project/mingw/MinGW%20automake/automake1.10/automake1.10-1.10.2-1/automake1.10-1.10.2-1-mingw32-bin.tar.lzma) alongside 1.11.
Libtool
You do not need any of the libltdl
tarballs.
Install
$ for f in *tar.gz ; do tar zxvf $f -C /mingw ; done $ for f in *tar.lzma ; do tar --lzma -xvf $f -C /mingw ; done
pkg-config
There are no MinGW or MSYS binaries for pkg-config, and building it from source is non-trivial due to a circular dependency on glib (you need pkg-config to build glib). However, the Gnome project distribute Windows binaries of both glib and pkg-config, which you can download from http://www.gtk.org/download-windows.html. They come in zip files, so you can just double-click them in Windows Explorer and copy the contents to your MinGW root (C:\MinGW
).
lex & yacc
Or rather, in our brave GNU world, flex (http://downloads.sourceforge.net/project/mingw/MSYS%20flex/flex-2.5.35-1/flex-2.5.35-1-msys-1.0.11-bin.tar.lzma) and bison (http://downloads.sourceforge.net/project/mingw/MSYS%20bison/bison-2.4.1-1/bison-2.4.1-1-msys-1.0.11-bin.tar.lzma). In addition, flex requires the GNU regex library (http://downloads.sourceforge.net/project/mingw/MSYS%20regex/regex-1.20090805-1/libregex-1.20090805-1-msys-1.0.11-dll-1.tar.lzma). Download and install as usual.
Boost jam
This utility is used to compile the Boost libraries. We're going to build it from source, so this is our baptism of MinGW fire…
Get the source tarball from http://downloads.sourceforge.net/project/boost/boost-jam/3.1.17/boost-jam-3.1.17.tgz; once you have it, it's a simple matter of running the build script (which will automatically detect MinGW) and installing the resulting executable:
$ tar zxf boost-jam-3.1.17.tgz $ cd boost-jam-3.1.17 $ sh ./build.sh $ mkdir -p /usr/local/bin $ cp bin.ntx86/bjam.exe /usr/local/bin $ which bjam /usr/local/bin/bjam.exe $ bjam -v Boost.Jam Version 3.1.17. OS=NT. Copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc. Copyright 2001 David Turner. Copyright 2001-2004 David Abrahams. Copyright 2002-2008 Rene Rivera. Copyright 2003-2008 Vladimir Prus.
It's alive!
Additional Unix utilities
You may want to install other programs, such as:
- libz (http://downloads.sourceforge.net/project/mingw/MinGW%20zlib/zlib-1.2.3-1-mingw32/libz-1.2.3-1-mingw32-dll-1.tar.gz and http://downloads.sourceforge.net/project/mingw/MSYS%20zlib/zlib-1.2.3-1/zlib-1.2.3-1-msys-1.0.11-dll.tar.gz) and gzip (http://downloads.sourceforge.net/project/mingw/MSYS%20gzip/gzip-1.3.12-1/gzip-1.3.12-1-msys-1.0.11-bin.tar.lzma)
Note that you should install *-mingw32-*
in /mingw
and *-msys-*
in /
:
$ for f in *-mingw32-*tar.lzma ; do tar --lzma -xvf $f -C /mingw ; done $ for f in *-msys-*tar.lzma ; do tar --lzma -xvf $f -C / ; done
Some tarballs are compressed with xz
(*.lzma
), some with bzip2
(*.bz2
), some with gzip
(*.gz
). Take care to use the correct tar options (–lzma
, –bzip2
or –gzip
) according to file type. However, once you've installed OpenSSL, all the compression libraries, libarchive and bsdtar, you can use bsdtar instead of GNU tar; bsdtar automatically detects the file type, so regardless of compression algorithm, you can just use bsdtar xvf <tarball> -C <destdir>
.
WiX
Microsoft's tool for creating installation packages: http://sourceforge.net/projects/wix/files/. Ironically, it does not come with its own installer.