Quant Lib

1.  Introduction

QuantLib is a set of libraries for quantitative finance. It is free and is distributed under a BSD-type licence. QuantLib is written in C++. Below are some step-by-step instructions of installing QuantLib together with a C++ compiler and an IDE (integrated developement environment).

2.  Installation in Windows XP

2.1  Install MinGW

MinGW is a set of freely available files including C, C++ and Fortran compilers for Windows. It stands for "Minimalistic GNU for Windows". You can find an installer here (sourgeforge.net); point at the file MinGW-XYZ.exe (where XYZ stands for the current release number). Save the file and run.

You can choose which compilers to download and install. Here we will only need the Base Tools, g++ (which is the C++ compiler) and the Make utility, but you can install everything if you have space. For example you might want to install g77 (which is a Fortran compiler) and/or the Java compiler. I have installed the compilers in the C:/MinGW folder.

It is worth verifying that the MinGW binaries are in your PATH. Go to Start > Control Panel > System, click on the Advanced tab and then click on the Environment Variables button. Double click on the PATH variable and check if the directory C:\MinGW\bin is somewhere in there. If yes then everything is fine. If not, just append it in the list of PATH directories and save.

2.2  Bloodshed C++

We now have the C++ compiler, and in principle we can start writing C++ code. But it would be a lot better if we had a decent editor and an envoronment from which we can monitor our projects. A nice free IDE (Integrated Developement Environment) is the Dev-C++.

To download and install the IDE you need to point here (sourceforge.net). The devcpp-XYZ_nomingw_setup.exe file will do the setup for you. I installed the IDE in the C:/Dev-Cpp folder.

Run the IDE and answer Yes to all questions. To test if everything is working you can create a simple project: Click on New > Project and save it in a folder (say My Documents/DevCpp). You can see a simple C++ program that does absolutely nothing :) Press the Compile and Run button (or hit F9), and save the main.cpp file as prompted. The file should compile and a DOS window should ask you to press any key (which you do). Then everything is setup fine.

You can close Dev-C++ for now.

2.3  The Boost libraries

QuantLib needs the set of Boost libraries to run properly. You have to download the files here (sourceforge.net). This is a bit trickier since you will need to download and compile the libraries yourself.

First you need to download the boost_XYZ.exe file and run it. This will unpack the libraries. I have extracted the files in the C:\Boost\Extracted directory. After everything is unzipped you can find a new directory C:\Boost\Extracted\Boost_XYZ. Within this directory there must be a file boost-build.jam, which we will use in the next stage.

To compile the libraries we need to also download the file boost-jam-XYZ-ntx86.zip by pointing once again here (sourceforge.net). You will now have to unzip this file and move bjam.exe to the directory where boost-build.jam is (that is C:\Boost\Extracted\Boost_XYZ).

The installation of the libraries will take place in DOS. Click Start > Run... on the Windows toolbar, and run cmd. A DOS window (now known as the command window) will open. Navigate yourself to the directory where bjam.exe and boost-build.jam are. Now at the command prompt execute the command

bjam "-sTOOLS=mingw" install

You can now go and get some coffee and cookies. It might take hours for the Boost libraries to get compiled...

After the compilation is complete you can close the command window. You also don't need the C:\Boost\Extracted folder and you can delete it. There are two new folders though: C:\Boost\lib which keeps the compiled Boost libraries for MinGW, and C:\Boost\include which keeps the C++ header files for each newly created Boost class.

Now you will need to tell Dev-C++ where the newly compiled libraries and the headers are. Open Dev-C++, go to Tools > Compiler Options and click on the Directories tab. You will need to set two directories for the Libraries and the C++ includes sub-tabs. The appropriate directories will be the C:\Boost\lib and C:\Boost\include\boost-XYZ, respectively. Fill in the corresponding filds and press Add.

2.4  QuantLib

The final step is to download, compile and configure QuantLib. You can download the soure code here (sourceforge.net). The file that you need is QuantLib-XYZ.zip, which you will download and unzip in C:\ (this will create a folder C:\QuantLib-XYZ, you can rename that to C:\QuantLib which looks better).

Now you want to compile these libraries with Dev-C++. Go to File > Open project or file and navigate to the QuantLib directory C:\QuantLib. There you can find the Dev-C++ project file QuantLib.dev which you open. In the project window you can see all classes that QuantLib offers.

Press the compile button (or hit Ctrl+F9), and the libraries will start to compile.

It takes about 20-30 minutes to build the libraries

Now we can test if everything is OK. Close Dev-C++ and reopen it. In the Quantlib folder there is a subfolder called Examples. In each example there is a XXXXX.dev file which you can open. If you press Compile and run you can check your installation. I found that sometimes Dev-C++ has a problem with the directories for some projects. You might need to right-click on the project name and choose Project options. There you might need to put the directories explicitly (eg C:\Quantlib\bin rather than .\bin or something like that)


Happy QuantLibbing :)

Kyriakos 20-12-06


What links here?


Got a question?

A short note

''To stop bots posting Viagra adverts as comments I have put a password in place. It just reads AEKARA, which you can use to edit the pages on this site. Sorry for any inconvenience but it was getting a real pain.

Comments(add/edit)

Y0TG5z <a href="http://aehvsuadfsij.com/">aehvsuadfsij</a>, [url=http://ohcfocvqzddz.com/]ohcfocvqzddz[/url], [link=http://jpfnuxcwddcv.com/]jpfnuxcwddcv[/link], http://sjubckuizkaw.com/