TUTORIAL: Boost 1.37.0 + QuantLib 0.9.6 and Visual Studio 2008

David Palmer

Senior Trader
I am about 12 years past my last programming (full-time) adventures. Then it was in C and I am looking to jump into Boost (www.boost.org) QuantLib (www.quantlib.org) using the MS Visual C++ Express Edition 2008.

I am using this on a Vista machine and have run into some linking issues. I thought that I might start a thread so I and interested others can go through this together.

If you haven't any knowledge of Boost and QuantLib, please take a look.

Dave
 

David Palmer

Senior Trader
The issue is less than XP vs Vista, the compiler release has yet to be intergrated in BJAM, which is used to build boost. So as a work around I edited the config files to build with the default MSVC. All of that eventually worked fine, but anytime I try to link using the regex libraries (regular expressions) it throws (MSVC) link errors. Now I could use Cygwin or G++ but then I have to keep using G++. My hope was to use the Express edition.

Once Boost gets built and runs fine, I will build QuantLib. Most of the development of these open source projects are done on Linux or Unix by nature.

My understanding and experience with previous versions was with a lot of digging around you get them built and running in MSVC, so I am sure it will get resolved. The community for both is vibrant and responsive. In the case of C++ 2008, it is just very new.

So I have to get past these link errors to move on. I browsed the forum here and did not see anything posted on QuantLib or Boost, fair to say I did not dig too deep though. Hoping to hook up with other interested parties to get through the learning curve togewther.
 

Vic_Siqiao

Member
do u have any guide on QuantLib? i once tried to use that, but encountered some compiler errors and didnt really know how to use those; hope someone develop a guide book or help file like that in Matlab.
 

David Palmer

Senior Trader
The online documentation is fairly robust, but the Windows guide requires a some digging to find all the quirks. To use QuantLib, you have to build boost then build QuantLib.

Boost is an extension to the STL. Some parts of boost are being adopted by the STL committee for use in upcoming releases.

Boost is very robust and constantly evolving. QuantLib is robust and constantly evolving, I think a windows group devoted to using QuantLib is in order.

I recently purchased "Beyond the C++ Standard Library" a great introduction to the power of Boost.

Dave
 

alain

Older and Wiser
I have used boost in the past. I know there is a way to obtain the full version without the need to build it. I remembered I used BJAM 2 years ago to build boost but last year I was able to find an installer for VS2005 somewhere on the boost website. I think this is the link

Boost Consulting - Free Downloads

I haven't used QuantLib or VS2008 though. boost might have issues with VS2008. Check the mailing lists and forums of boost. They are pretty helpful.
 

David Palmer

Senior Trader
Thanks Alain, the latest is good for 2005 compiler, but needs to be built for 2008. Usually there is backward compatability so some simple configuration changes to the bjam build and you are off and running. I was able to build them ok, but for some reason the linker is unhappy.

libboost_regex-vc80-mt-gd-1_34_1.lib(usinstances.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) "BLAH BLAH BLAH"

the -gd- in the library name signifies a debug library, so it has problems with the debug library. Both the release and debug libraries are there. Not a pro at C++2008 yet, so I am stuck.

Dave
 

alain

Older and Wiser
Thanks Alain, the latest is good for 2005 compiler, but needs to be built for 2008. Usually there is backward compatability so some simple configuration changes to the bjam build and you are off and running. I was able to build them ok, but for some reason the linker is unhappy.

libboost_regex-vc80-mt-gd-1_34_1.lib(usinstances.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) "BLAH BLAH BLAH"

the -gd- in the library name signifies a debug library, so it has problems with the debug library. Both the release and debug libraries are there. Not a pro at C++2008 yet, so I am stuck.

Dave
Don't assume backward compatibility with MSVC++ with libraries that don't come from MS. There is probably something in there that is breaking the whole thing.

I remember in another sombody was having problems compiling an Excel add-in and there was a switch in the VC++ to produce somekind of old code. I think you should hit the forums and try to find out. Also, is VS2008 out officially? I haven't checked lately. If it is not, you might be getting into uncharted territories.
 

DaveCompton

New Member
building quantlib and boost with msvc express edition 2008

I've been able to build both boost 1.34.1 and quantlib 0.9.0 using msvc express edition 2008. It took a few tweaks to both the boost and quantlib code.

If this is still of interest, let me know and I can post more details.

- Dave
 

alain

Older and Wiser
I've been able to build both boost 1.34.1 and quantlib 0.9.0 using msvc express edition 2008. It took a few tweaks to both the boost and quantlib code.

If this is still of interest, let me know and I can post more details.

- Dave
Any detail is going to be well received :)
 
Hey Dave

I'm right now trying to make QuantLib (0.8.1) work with Boost on an XP machine, with VS C++ 2008. I am really interestered in hearing about your experience. Boost is working fine, but I have some trouble with the compiler version and QuantLib.

The file ql/config.msvc.hpp does not "know" about versions of VS C++ newer than 2008 (version 9). To solve this I simply copied the code snippet concerning version 9 to the statement producing the error message "unknown compiler". So far, so good.

Next step was to update all filepaths in the project properties so that all projects in the QuantLib solution could find the relevant headers etc.

Now I'm stuck though. All projects fail to link to the library file QuantLib-vc80-mt-gd-0_8_1.lib. No wonder, because the file does not appear on my harddrive. I suppose I have done something not ideal in the above described steps.

Have you any thoughts about what could be my problem? How have you overcome these difficulties?

Best regards and thanks in advance

Peter
 

DaveCompton

New Member
Hi Peter,

I ran into similar problems with quantlib 0.9.0 . The solution your "fail to link" errors might be as simple as just changing the name of the library generated in the quantlib project to QuantLib-vc80-mt-gd-0_8_1.lib . This is something of a hack but since you've gotten this far, it is worth a try. The Visual Studio setting for the library name is under "Project/Properties/Configuration_Properties/Librarian/General"

In more detail, there are files in both quantlib and boost that are compiler version related.

In quantlib (0.9.0 and 0.8.1 ) these are :
ql/auto_link.hpp and
ql/config.msvc.hpp (you saw this one already) .

I also had to modify QuantLib-0.9.0/ql/utilities/tracing.hpp to get it to compile under VS 2008. The same change may or may not be necessary for QuantLib-0.8.1/ql/utilities/tracing.hpp

In boost 1.34.1, the compiler version related changes are :
'boost_1_34_1/boost/config/auto_link.hpp'
'boost_1_34_1/boost/config/compiler/visualc.hpp'
'boost_1_34_1/tools/build/v2/tools/msvc.jam'

I also had to modify:
'boost_1_34_1/boost/signals/detail/named_slot_map.hpp'
'boost_1_34_1/libs/signals/src/named_slot_map.cpp'

to get them to compile under VS 2008.

Without knowing which version of boost you are using or whether it came pre-compiled or you built it yourself, I can't say too much more about your specific situation.

I am going to follow this post shortly (in the next hour or so) with another post with links to much more detailed instructions on how to build both boost 1.34.1 and quantlib 0.9.0 using VS 2008. My intention is for these to be instructions that anyone can use to build quantlib 0.9.0 using VS 2008 starting with just a windows installation and an internet connection. If you get a chance to try out these links, would you please give me any feedback you might have?

Thanks!

- Dave
 

DaveCompton

New Member
Hey Dave

Thanks a lot. I have been away for some days but will now try out your suggestions. Furthermore I will have a look on your links. Give me a couple of hours...

Peter
 

DaveCompton

New Member
Hi Peter,

I don't know if using QuantLib version 0.8.1 in particular is important to you or not but the patch I linked to in my blog will not work for that version. However, the *changes* caused by that patch in version 0.9.0 are the same changes needed for 0.8.1 . You can probably just look at the text of the patch and see what needs to be done. I built 0.8.1 last week without any problems.

- Dave
 

John Donahue

New Member
I followed Dave Programming blog to get Boost and QuantLib running on XP with VS Express C++ and it works great! Thanks so much for the help! Just have to make sure to get projects built you have the project properties point to the correct directories and libraries.

Anyone using GNU GSL for calculations?
 

tkhin

New Member
thank you dave for your guide.
managed to make quantlib work in visual studio 2005, seems to be ok now..
 

Andy Nguyen

Member
I tried this the other day and couldn't get it to work on Visual Studio 2008 Team edition.
Code:
C:\boost_1_34_1>boost_1_34_1___vs2008___patch.txt | patch -p0
didn't seem to be the correct syntax so I changed it to
Code:
C:\boost_1_34_1>patch -p0 <boost_1_34_1___vs2008___patch.txt
can't find file to patch at input line 25
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
It points to lines like this
@@ -168,8 +168,8 @@
 

DaveCompton

New Member
Hi Andy,

You're right -

Code:
C:\[B][COLOR=Black]boost_1_34_1___vs2008___patch.txt | patch -p0[/COLOR][/B]
is not the correct syntax. The alternative that you tried will not work either.


The correct syntax (as specified in the text of the patch) is:

Code:
C:\[B][COLOR=Black]type boost_1_34_1___vs2008___patch.txt | patch -p0[/COLOR][/B]
Also, you may not be getting the correct patch command. I installed the patch.exe program from Patch for Windows (also specified in the text of the patch) and then invoked it by full path name as follows:

Code:
C:\[B][COLOR=Black]type boost_1_34_1___vs2008___patch.txt | "c:\Program Files\GnuWin32\bin\patch.exe" -p0[/COLOR][/B]
I have not tried Visual Studio Team Edition but I have tried Visual Studio Express Edition and Visual Studio Professional Edition and found that the instructions that I specify work for both.

- Dave
 
Top