Portable C++ on Windows: Part 2 – Libraries

In the previous post in my series on Portable C++ on Windows, Compilers and Command Lines, we walked through the steps required to set yourself up with a windows-based C++ development environment which doesn’t rely on the Microsoft platform. We walked through getting set up with MinGW (GCC for Windows), MinGW-MSYS (BASH for Windows) and more recent versions of the GNU Autotools for your shiny BASH shell.

This time, we will walk through building the Boost libraries and the Xerces C++ XML library. Now, I know I mentioned in the first part that we would cover SFML as well, but this comes pre-built for windows, so we don’t need to worry about that (we will cover installing it and building a small example with it in the next part of this series).


First things first, you need to get hold of the Boost libraries, and also Boost Jam, which is the Boost build system. Use the links below. If you’re from the future you might want to go to boost.org and get the latest versions, but at the time of writing the links below were to the latest versions.

I unzipped the Boost JAM archive so that bjam.exe was in c:boostjam, and then used WEVE to edit my PATH environment variable so that the boostjam folder was on it. The next thing you’ll want to do is extract the Boost 1.37.0 archive so that you end up with a folder like c:librariesboost_1_37_0.

Next, fire up MSYS (make sure you are running as an administrator, especially if you are on Vista, with UAC turned on). Change directory to /c/libraries/boost_1_37_0 and then run ./configure. After this has completed you should have a file called user-config.jam. Mine looked like this:

# Boost.Build Configuration
# Automatically generated by Boost configure

# Compiler configuration
using gcc ;

Now open up a windows command prompt (cmd.exe) and navigate to c:librariesboost_1_37_0 and invoke the following commands:

copy user-config.jam toolsbuildv2user-config.jam
bjam debug -toolset=gcc stage

You’ll have to sit and wait for some time, but eventually you’ll have about 4GB of lib and dll files in the stagelib folder.


We’re going to cover building the Xerces 3.0.0 XML library for C++. First, you’ll need to grab the source code and unzip it into the c:libraries folder as well. You should end up with a folder like c:librariesxerces-c-3.0.0. Fire up MSYS again if you closed it, and change directory to /c/libraries/xerces-c-3.0.0 and run:

./configure LDFLAGS=-no-undefined && make && make install

Again, you will have to sit for a while. When everything has completed you should be able to find the Xerces libraries in c:msys1.0locallib unless you installed MinGW-MSYS somewhere else.

That’s all for this part and I hope that everything went smoothly – if it didn’t, drop me a comment and I’ll try to help you out – next time we’ll be covering setting up the Eclipse CDT to use the tools we installed in Part 1, and also how to choose which libraries to link to.

Portable C++ on Windows: Part 1 – Compilers and Command Lines

Danushka and I decided to start a new game engine, and this time portability and simplicity are our two major concerns. The portability is mainly because Danu wants to use linux, and I don’t. Even if we were’t going for portability, we would probably still try to use open tools like Eclipse CDT because the Eclipse platform will allow us to maintain a completely integrated development environment for the engine, including any custom tooling needed for the engine, right through to the end-users of the engine (the game developers).

So, as you may have guessed by now, our tool-chain focusses around the Eclipse CDT (C/C++ Development Tools). In order to use this on windows, you’re going to need a version of gcc, and if you want to build any libraries you’ll probably need a BASH-esque command line replacement. So the tool-chain I am using is this:

  • Eclipse CDT (Gaynemede/3.4)
  • MinGW
  • MinGW-GDB
  • MinGW-MSYS

Also, to facilitate portable development we are using a couple of libraries, namely:

  • Boost
  • SFML
  • Xerces

This first part in my series on “Portable C++ on Windows” will discuss setting up MinGW, MinGW-GDB and MinGW-MSYS. The second part will discuss building Boost, SFML and Xerces, and the third will show you how to put it all together in the Eclipse CDT.

Part 1 – Compilers and Command Lines

These instructions are based on my experiences following these instructions. I am running Vista, and I have hand-picked a combination of the versions of the tools listed below because they worked for me. I also did things slightly differently to the aforementioned instructions because I ran into problems. If you have any problems, drop me a comment and I’ll try get back to ya.

Yout first step should be to download the following (just download them, don’t do anything with them yet):

Ok, step 2: Install MinGW to c:MinGW.  It is a very good idea to install into a path where there are no spaces, MinGW doesn’t really like them. The post install process will run, follow it through, it’s quite straight-forward.

Step 3: Install GDB into the c:MinGW folder. The archive contains a folder structure that is analogous to the c:MinGW folder, so merge the two. gdb.exe should end up in c:MinGWbin.

Step 4 is to install MinGW-MSYS, run the installer, telling it to install in c:msys1.0. This will install version 1.0.10. Extract the update archive (version 1.0.11) into the c:msys1.0 folder. Again the archive’s structure is analogous to the installed structure so the two should merge.

Step 5: Install the msys dtk by running the installer.

Step 6: Install the latest version of m4. Make sure that m4.exe goes into c:msys1.0bin

By now you should have an “M” icon on your desktop. Make sure you always choose to “Run As Administrator” for this if you are on Vista and you’re not a local admin (But don’t run it yet).

Step 7: Extract the automake, autoconf and libtool archives to c:temp (they will each then have their own folder, eg c:tempautomake-1.10 etc…)

Step 8: Run msys as administrator. You are now presented with a unix-esque command line. Directories are mounted so that all of your c-drive contents are under /c, so c:temp would be /c/temp. Change directory into each of the folders extracted in step 7, and run the following:

./configure --prefix=/mingw && make && make install

If you have problems building or installing the above, you may not be running as administrator.

Step 9: Get a real text editor, like TextPad, or Notepad++ (or any other one that allows you to choose your line ending type, we want LF endings), and edit C:msys1.0etcprofile. Make the following changes:

Find the line that says:


and replace it with:


Then add the following immediately before the line you just changed:

CFLAGS="-pipe -O2 -mms-bitfields -march=i686"

That’s it. Close MSYS and re-open it, and you should be away laughing. Stay tuned for the next part of the series on building Xerces, Boost and SFML (we may not have to build SFML).