- Joined
- 2/3/08
- Messages
- 29
- Points
- 11
Building Boost 1.35.0 + Quantlib 0.9.0 with Visual Studio 2008
These instructions are for building Boost 1.35.0 + Quantlib 0.9.0 with Visual Studio 2008 (VS2008). The instructions have been successfully tested on Team Edition, Professional Edition and Express version of VS2008.
WARNING: We assume that you have VS2008 (for Team Edition) or Visual C++ 2008 (Express version) fully working before attempt to use this guide.
To use Quantlib, you have to build Boost first.
STEP 1: Install and build Boost 1.35.0
To build Boost you will need The Microsoft Windows SDK for VS2008 . This is available as an option when installing Visual Studio 2008.
You can also download it from Microsoft website at http://www.microsoft.com/downloads/...23-93ca-479a-867c-04dc45164f5b&displaylang=en
The file you want to download is VsSDK_sfx.exe (96.5 MB)
To run Visual C++ (vc++) from the command prompt you will need some msvc related environment variables. Msvc comes with a batch file that sets these environment variables. An easy way to use this batch file is to copy the "Start/All Programs/Accessories/Command Prompt" short cut from the start menu to your desktop and then change the short cut target property to %SystemRoot%\system32\cmd.exe /K call "C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"
After doing this, this short cut should bring up a command environment ready to run vc++. All the command line work described in the remainder of this post should be done using a cmd window in which vcvarsall.bat has been run ( whether through the shortcut just described or by some other means ).
Download boost 1.35.0 from sourceforge.net and uncompress. I used the zip file here:
http://internap.dl.sourceforge.net/sourceforge/boost/boost_1_35_0.zip
Download and unzip Boost into your C: drive. You should have a new directory called C:\boost_1_35_0
Now it's time to build bjam (the boost build tool) from the cmd shell as follows:
This should build src\bin.nt\bjam.exe, the command that you will use to build the rest of boost. You may see a few errors which you can ignore as long as bjam.exe gets built.
After making these changes, go to the top level directory: C:\boost_1_35_0 (THIS IS VERY IMPORTANT) and type:
All of the boost libraries will get built. This may take several hours depending on the speed of your computer. When complete, type:
This will take a few more minutes. When done, this will build the boost libraries and install them in C:\Boost
When you want to build a program that uses the boost toolkit, you will need to let the compiler and linker know where to find the boost files. Do this from within VS2008, by selecting "Tools/Options/Projects and Solutions/VC++ Directories" (starting from the menu bar and ending up in a dataform), and adding C:\Boost\include\boost-1_35 to the include directories and C:\Boost\lib to the Library directories.
STEP 2: Install and build Quantlib 0.9.0
Quantlib will not work without Boost. Attempt this step only AFTER you complete STEP 1 above.
Download quantlib 0.9.0 from here:
http://superb-east.dl.sourceforge.net/sourceforge/quantlib/QuantLib-0.9.0.zip
Unzip and extract it to your C:\ drive. When done, you should have a new folder: C:\QuantLib-0.9.0
The quantlib 0.9.0 code needs some changes to work with VS2008.
A patch is attached to this message that can be used to make all the code changes necessary for quantlib 0.9.0 to compile and link under VS2008. Save it to text file called patch.txt on your C:\ drive (THIS IS IMPORTANT).
To apply the patch you will need to have the patch program in your %PATH% or use the full path name to the patch program. The patch program can be downloaded from:
http://internap.dl.sourceforge.net/sourceforge/gnuwin32/patch-2.5.9-7-setup.exe
Download and install this as a regular program.
To apply the patch using a dos command shell, move to C:\ directory and type the following command:
If done correctly, you will see the following output:
At the top level of the quantlib source code tree (QuantLib-0.9.0) is a "msvc solution" file: QuantLib_vc8.sln . Open this with VS2008. You will be asked if you want to convert older solutions/projects to the latest version. Answer yes and let the conversion proceed.
STEP 3: Test Quantlib sample code
If you follow STEP 1 and 2 correctly, now you should be able to build and run your Quantlib code.
When you open Quantlib_vc8.sln, under Solution Explorer, you will see 11 examples:
Right click on QuantLib and select Set As Startup Project, then right click and select Build.
This will take a while for Quantlib to build all links. BE PATIENCE.
When the build is complete, right click on one of the other examples (Repo) and repeat the same steps you did for Quantlib. When done, click F5 to run the Repo example.
This should be the output of the code
Thank you, Andy, for proofreading and significantly improving these instructions.
These instructions are for building Boost 1.35.0 + Quantlib 0.9.0 with Visual Studio 2008 (VS2008). The instructions have been successfully tested on Team Edition, Professional Edition and Express version of VS2008.
WARNING: We assume that you have VS2008 (for Team Edition) or Visual C++ 2008 (Express version) fully working before attempt to use this guide.
To use Quantlib, you have to build Boost first.
STEP 1: Install and build Boost 1.35.0
To build Boost you will need The Microsoft Windows SDK for VS2008 . This is available as an option when installing Visual Studio 2008.
You can also download it from Microsoft website at http://www.microsoft.com/downloads/...23-93ca-479a-867c-04dc45164f5b&displaylang=en
The file you want to download is VsSDK_sfx.exe (96.5 MB)
To run Visual C++ (vc++) from the command prompt you will need some msvc related environment variables. Msvc comes with a batch file that sets these environment variables. An easy way to use this batch file is to copy the "Start/All Programs/Accessories/Command Prompt" short cut from the start menu to your desktop and then change the short cut target property to %SystemRoot%\system32\cmd.exe /K call "C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"
After doing this, this short cut should bring up a command environment ready to run vc++. All the command line work described in the remainder of this post should be done using a cmd window in which vcvarsall.bat has been run ( whether through the shortcut just described or by some other means ).
Download boost 1.35.0 from sourceforge.net and uncompress. I used the zip file here:
http://internap.dl.sourceforge.net/sourceforge/boost/boost_1_35_0.zip
Download and unzip Boost into your C: drive. You should have a new directory called C:\boost_1_35_0
Now it's time to build bjam (the boost build tool) from the cmd shell as follows:
Code:
cd boost_1_35_0\tools\jam\src
build.bat
After making these changes, go to the top level directory: C:\boost_1_35_0 (THIS IS VERY IMPORTANT) and type:
Code:
tools\jam\src\bin.ntx86\bjam.exe --build-type=complete
Code:
tools\jam\src\bin.ntx86\bjam.exe --build-type=complete install
When you want to build a program that uses the boost toolkit, you will need to let the compiler and linker know where to find the boost files. Do this from within VS2008, by selecting "Tools/Options/Projects and Solutions/VC++ Directories" (starting from the menu bar and ending up in a dataform), and adding C:\Boost\include\boost-1_35 to the include directories and C:\Boost\lib to the Library directories.
STEP 2: Install and build Quantlib 0.9.0
Quantlib will not work without Boost. Attempt this step only AFTER you complete STEP 1 above.
Download quantlib 0.9.0 from here:
http://superb-east.dl.sourceforge.net/sourceforge/quantlib/QuantLib-0.9.0.zip
Unzip and extract it to your C:\ drive. When done, you should have a new folder: C:\QuantLib-0.9.0
The quantlib 0.9.0 code needs some changes to work with VS2008.
A patch is attached to this message that can be used to make all the code changes necessary for quantlib 0.9.0 to compile and link under VS2008. Save it to text file called patch.txt on your C:\ drive (THIS IS IMPORTANT).
To apply the patch you will need to have the patch program in your %PATH% or use the full path name to the patch program. The patch program can be downloaded from:
http://internap.dl.sourceforge.net/sourceforge/gnuwin32/patch-2.5.9-7-setup.exe
Download and install this as a regular program.
To apply the patch using a dos command shell, move to C:\ directory and type the following command:
Code:
C:\type patch.txt | "c:\Program Files\GnuWin32\bin\patch.exe" -p0
Code:
patching file QuantLib-0.9.0/QuantLib_vc8.vcproj
patching file QuantLib-0.9.0/ql/auto_link.hpp
patching file QuantLib-0.9.0/ql/config.msvc.hpp
patching file QuantLib-0.9.0/ql/utilities/tracing.hpp
STEP 3: Test Quantlib sample code
If you follow STEP 1 and 2 correctly, now you should be able to build and run your Quantlib code.
When you open Quantlib_vc8.sln, under Solution Explorer, you will see 11 examples:
Code:
BermudanSwaption
ConvertibleBonds
DiscreteHedging
EquityOption
FittedBondCurve
FRA
QuantLib
Replication
Repo
Swap
testsuite
This will take a while for Quantlib to build all links. BE PATIENCE.
When the build is complete, right click on one of the other examples (Repo) and repeat the same steps you did for Quantlib. When done, click F5 to run the Repo example.
This should be the output of the code
Code:
Underlying bond clean price: 89.9769
Underlying bond dirty price: 93.288
Underlying bond accrued at settlement: 3.31111
Underlying bond accrued at delivery: 3.33333
Underlying bond spot income: 3.9834
Underlying bond fwd income: 4.08465
Repo strike: 91.5745
Repo NPV: -2.64151e-005
Repo clean forward price: 88.2411
Repo dirty forward price: 91.5745
Repo implied yield: 5.000060 % Actual/360 simple compounding
Market repo rate: 5.000000 % Actual/360 simple compounding
Compare with example given at
[URL="http://www.fincad.com/support/developerFunc/mathref/BFWD.htm"]Bond Forwards and Futures[/URL]
Clean forward price = 88.2408
In that example, it is unknown what bond calendar they are
using, as well as settlement Days. For that reason, I have
made the simplest possible assumptions here: NullCalendar
and 0 settlement days.
Run completed in 0 s