Settingup Boost GCC Windows

A lot of the power of C++ comes from the STL, the C++ Standard Library. And even more power is available using the Boost libraries, which are about to become part of the upcoming new STL version. Thus, using Boost libraries in your project is not even very convenient, it will also guarantee compatibility between platforms and future STL releases. (To all you C++ gurus out there: I hope this short introduction is not too misleading.)

While the Boost libraries are easy to install on Unix machines and the Boost websites offers binaries for Visual C++ 2005, it is more complicated to use Boost on Windows with the GNU Compiler Collection (aka gcc). In fact, it took me several hours to figure out how to use Boost with my favourite IDE, Netbeans. Netbeans? The Java IDE from Sun? Yes, I prefer Netbeans over Eclipse, because Netbeans is easier to use, but it is still a full-featured IDE and it even has a greatC/C++-Plugin.

After doing some experiments with MingW, I decided that Cygwin would be a better choice. (Maybe I was just to stupid to get things working with MingW.) Here’s what you have to do to get Boost, cygwin with gcc/g++ and Netbeans working under Windows.

Install Cygwin. Make sure that you also install gcc, g++, boost, make and gdb – you should find all of them within the Devel section of the Cywin installer.

Now open a windows command prompt and execute the following statements: ‘gcc –version’, ‘g++ –version’, ‘make –version’ and ‘gdb –version’. You should get something like this:C:Dokumente und Einstellungensf>gcc --versiongcc (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)Copyright (C) 2004 Free Software Foundation, Inc.This is free software; see the source for copying conditions. There is NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Now install Netbeans. After installation, open Tools – Plugins. Under “Available Plugins” you should see “C/C++”. Install this plugin and restart Netbeans.

Now open, again in Netbeans, Tools – Options – C/C++. In the section “Build Tools” click “Add ..” and choose your Cygwin bin directory (C:cygwinbin) as your base directory and click “Okay”. Netbeans now finds all your compiler and make tools from the Cygwin installation.

In the section “Code Assistance” you have to choose the sub-section “C++ Compiler”. Add the include directory for your Boost libraries: In my installation this is C:cygwinusrincludeboost-1_33_1. Click “Okay”.

Create a new Netbeans C++ project and write some code. Right click your project and choose “Set Configuration – Manage Configurations …”. In the “C++ Compiler” section, include the path to your Boost libraries int the “Include Directories” folder. My path is C:cygwinusrincludeboost-1_33_1.

In the “Linker” section put your Cygwin bin directory (C:cygwinbin) in the “Additional Library Directories” field. Then edit the “Libraries” field below: Click “Add Library File …”, change file type to “.dll” and choose the libraries you need for your project. For my small regex example, I need cyboost_programm_options-gcc-mt-1_33_1 and cyboost_regex-gcc-mt-1_33_1.