• C++ Programming for Financial Engineering
    Highly recommended by thousands of MFE students. Covers essential C++ topics with applications to financial engineering. Learn more Join!
    Python for Finance with Intro to Data Science
    Gain practical understanding of Python to read, understand, and write professional Python code for your first day on the job. Learn more Join!
    An Intuition-Based Options Primer for FE
    Ideal for entry level positions interviews and graduate studies, specializing in options trading arbitrage and options valuation models. Learn more Join!

TUTORIAL: Boost 1.37.0 + QuantLib 0.9.6 and Visual Studio 2008

Dave,
Thanks for feedback. Also, you should save the patch files to a txt files on your site, don't remote link it. My work firewall blocks the sites that host the patch so I suppose a few people won't be able to get it as well.
I download the patch program and setup the path in my environment so I don't have to use the full path. It took a while to search for the patch program from the link in your guide.
When I saw "type boost..." I thought I should type "boost..." ;)
I will try it tomorrow on my work machines and report back.
Do I have to go through with all the boost and quantlib installation first before attempting your patches ?
 
Also, you should save the patch files to a txt files on your site, don't remote link it. My work firewall blocks the sites that host the patch so I suppose a few people won't be able to get it as well.


I don't have a "site" as such. Just the blog and the remotely hosted files that I have linked to. The blog is just a blogger.com freebie. As far as I can tell there's no good way to attach text files to a blog entry other than just linking to a location outside of the blog. I could put them somewhere else but some others would probably still have the same access problem as you do now. For now I'm going to leave them where they are but I'm open to suggestions if you or anyone else has a specific alternative in mind.


I download the patch program and setup the path in my environment so I don't have to use the full path. It took a while to search for the patch program from the link in your guide.
When I saw "type boost..." I thought I should type "boost..." ;)

I figured that was what happened. When I get a chance I will put some more detail into the instructions both to avoid the "type" mis-interpretation and to make the patch program easier to find.

Do I have to go through with all the boost and quantlib installation first before attempting your patches ?


It's probably a good idea to start from scratch as much as possible. The bulk of your time will be taken up by compiling boost so if you're going to do that anyway, it is probably worth going the extra mile to make sure that you are not starting from a codebase that has been corrupted in some subtle way.

Here is what the output should look like when you apply the boost patch:

C++:
C:\type boost_1_34_1___vs2008___patch.txt | "c:\Program Files\GnuWin32\bin\patch.exe" -p0
patching file boost_1_34_1/boost/config/auto_link.hpp
patching file boost_1_34_1/boost/config/compiler/visualc.hpp
patching file boost_1_34_1/boost/signals/detail/named_slot_map.hpp
patching file boost_1_34_1/libs/signals/src/named_slot_map.cpp
patching file boost_1_34_1/tools/build/v2/tools/msvc.jam
Here is what the output should look like when you apply the quantlib patch:

C++:
 C:\type quantlib-0.9.0___vs2008___patch.txt | "C:\Program Files\GnuWin32\bin\patch.exe" -p0
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
 
Dave,
You da man. This helps a lot.
As for the "patch", since they are text, you should just post the content on your blog with instruction to save as .txt
Have you used boost/quantlib for anything interesting? If so, share with us here Let's code ! - QuantNetwork - Financial Engineering Forum

I try to get this to work so I can use some of this in my production code.
 
SUCCESS !:dance:
The trick that worked for me is to put the patch files on C:\ instead of under \quantlib and \boost folders.
The boost build took a while but I finally got a sample code to run with boost header

The patch for quantlib is a bit uncertain as this is what returned when i patched it
C++:
C:\>type quantlib-0.9.0___vs2008___patch.txt | patch -p0
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
patch unexpectedly ends in middle of line
Hunk #1 succeeded at 62 with fuzz 1.
I've been able to build the quantlib testsuite but haven't run any code yet to see if it works.

Thanks, Dave.
Boost 1.35 is out, any twist to build it ?
 
All the quantlib examples work fine now. The build time is a bit long but as far as I can tell, everything is working.
Here is the output of BermudanSwaption code
C++:
G2 (analytic formulae) calibration
1x5: model 10.07620 %, market 11.48000 % (-1.40380 %)
2x4: model 10.51717 %, market 11.08000 % (-0.56283 %)
3x3: model 10.69988 %, market 10.70000 % (-0.00012 %)
4x2: model 10.83021 %, market 10.21000 % (+0.62021 %)
5x1: model 10.93331 %, market 10.00000 % (+0.93331 %)
calibrated to:
a     = 0.049916, sigma = 0.0094397
b     = 0.049917, eta   = 0.0094396
rho   = -0.764

Hull-White (analytic formulae) calibration
1x5: model 10.69370 %, market 11.48000 % (-0.78630 %)
2x4: model 10.58342 %, market 11.08000 % (-0.49658 %)
3x3: model 10.68811 %, market 10.70000 % (-0.01189 %)
4x2: model 10.66578 %, market 10.21000 % (+0.45578 %)
5x1: model 10.57737 %, market 10.00000 % (+0.57737 %)
calibrated to:
a = 0.048506, sigma = 0.0059887

Hull-White (numerical) calibration
1x5: model 10.34451 %, market 11.48000 % (-1.13549 %)
2x4: model 10.55123 %, market 11.08000 % (-0.52877 %)
3x3: model 10.66531 %, market 10.70000 % (-0.03469 %)
4x2: model 10.73173 %, market 10.21000 % (+0.52173 %)
5x1: model 10.78596 %, market 10.00000 % (+0.78596 %)
calibrated to:
a = 0.054928, sigma = 0.0060879

Black-Karasinski (numerical) calibration
1x5: model 10.35848 %, market 11.48000 % (-1.12152 %)
2x4: model 10.57066 %, market 11.08000 % (-0.50934 %)
3x3: model 10.67466 %, market 10.70000 % (-0.02534 %)
4x2: model 10.72826 %, market 10.21000 % (+0.51826 %)
5x1: model 10.76667 %, market 10.00000 % (+0.76667 %)
calibrated to:
a = 0.043131, sigma = 0.12039

Payer bermudan swaption struck at 5.00000 % (ATM)
G2:       14.081
HW:       13.105
HW (num): 13.127
BK:       12.972
Payer bermudan swaption struck at 6.00000 % (OTM)
G2:       3.2533
HW:       2.5975
HW (num): 2.5988
BK:       3.2555
Payer bermudan swaption struck at 4.00000 % (ITM)
G2:       42.596
HW:       42.333
HW (num): 42.351
BK:       41.816

Run completed in 4 m 18 s
 
Andy,

I'm glad to hear that everything came together. I'm trying out boost 1.35.0 now. No patches are required :). The only thing that is a little different is that when you run bjam, you need to specify "--build-type=complete" to build the entire set of libraries. If you don't specify --build-type it defaults to --build-type=minimal which does not compile anything. Actually though, for quantlib, it appears that the only *compiled* library that you need is the testing framework so you may be able to specify a limited build-type that builds only the testing code. I didn't try to figure out how though.

- Dave
 
I think making it a sticky will be a great idea.
 
Hello i followed the steps on how to compile ql with vs2008-- still getting one error:
10>LINK : fatal error LNK1104: cannot open file 'libboost_unit_test_framework-vc90-mt-gd-1_35.lib'

Thanks in advance for any solutions
 
Guys,

The library that this error specifies is the correct file ( 'libboost_unit_test_framework-vc90-mt-gd-1_35.lib' ) so either it is not in the right place or VC++ is looking for it in the wrong place.

Was boost 1.35 built and installed as follows?:

C++:
bjam --build-type complete
bjam --build-type complete install
If so , then the library should exist under C:\Boost\lib
If it is there then check the VC++ "Tools/Options/Projects and Solutions/VC++ Directories/Library Files" to make sure that the list of directories includes "C:\Boost\lib"

Of course if boost was installed in some other location, the above notes should be adjusted appropriately.

Please let me know if and how things work out.

- Dave


Now confirm that I was able to install and build boost 1.35 without patch.
Follow Dave's guide to patch quantlib but when I went to compile and build the quantlib sample code, I had the same error as Andrew
Error 1 fatal error LNK1104: cannot open file 'libboost_unit_test_framework-vc90-mt-gd-1_35.lib'
 
Yes all you have to do is redo the bjam install step again. It would probably be a good idea to move your old install directory to a different name ( or delete it ) before doing the install so that you know that you are getting a fresh new install.

Ah hah. I think that's what I missed. I didn't use the build-type=complete in the install step. I only used it the first time I build bjam.
I will try as soon as I get home and report back. Speaking of this, all I have to do is redo the bjam install step again?
 
I checked my installation of Boost. C:\Boost\lib is included in VC++ 2008. But when I compile and make link of QuantLib, I have the following link error: fatal error LNK1104: can not open file 'QuantLib-vc90-mt-sgd-0_9_0.lib'. What is the problem then?
 
Hi Jonylee,

Something might be wrong with your choice of configurations for one or some of your projects in the quantlib solution. To check this, bring up the configuration manager ( from the button in the upper right corner of any project/properties form). The configurations for all projects should be set to "Debug CRTDLL" . If this is not the case, set appropriately and rebuild all the quantlib stuff.

Please let me know how things go.

- Dave


I checked my installation of Boost. C:\Boost\lib is included in VC++ 2008. But when I compile and make link of QuantLib, I have the following link error: fatal error LNK1104: can not open file 'QuantLib-vc90-mt-sgd-0_9_0.lib'. What is the problem then?
 
Hi, Dave

I followed your instruction and now I got Andy's problem: Error 1 fatal error LNK1104: cannot open file 'libboost_unit_test_framework-vc90-mt-gd-1_35.lib' . Seems I have to reinstall Boost.
 
Hi Jonylee,

That's progress. Be sure to use the "--build-type=complete" option for both build and install:

C++:
bjam --build-type complete
bjam --build-type complete install
- Dave

Hi, Dave

I followed your instruction and now I got Andy's problem: Error 1 fatal error LNK1104: cannot open file 'libboost_unit_test_framework-vc90-mt-gd-1_35.lib' . Seems I have to reinstall Boost.
 
Back
Top