Getting started with Quantlib on MS Visual C++ 2005 Express
Posted by
Imbs XNI Xavier-Nicolas (DCLNY) on
URL: http://quantlib.414.s1.nabble.com/DEV-c-tp4940p4941.html
Hello
everyone,
I just started to
have a look on Quantlib and I wanted to compile it but I couldn't find a strait
forward tutorial on how to compile Quantlib from scratch.
Spending some time
findin different pieces of information on the web, I just listed below the
different points to get Quantlib working from a user's point of view with VC++
2005. I hope that I could be helpful and that it can save some time to future
starters.
Best
regards,
Xavier
*************************************************************************************************
*
HOW TO COMPILE QUANTLIB WITH VISUAL C++ 2005 EXPRESS. July 2006.
*
*
THE NEWBIE
GUIDE
*
*************************************************************************************************
- Download the free
Microsoft Visual C++ 2005 Express Edition from
http://msdn.microsoft.com/vstudio/express/visualc/download/
-
Download the free Microsoft Platform SDK (my version is of March 2006) from
http://www.microsoft.com/downloads/details.aspx?FamilyId=0BAF2B35-C656-4969-ACE8-E4C0C0716ADB&displaylang=en
the
file is PSDK-x86.exe.
- Install Visual C++ 2005 Express to the default
directory : "C:\Program Files\Microsoft Visual Studio 8\"
and Platform
SDK to "C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK" because this
directory name seems apparently to be preconfigured in a default
installation of Visual C++ 2005 Express.
- After installations are completed,
you will need to manually edit vsvars32.bat file
in directory (default
is "C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\" )
and
append full path to Platform SDK include, lib and bin subdirectories to
respectively INCLUDE, LIB and PATH environment variables that are set
in this batch file.
Hence add :
"C:\Program Files\Microsoft
Visual Studio 8\VC\PlatformSDK\Include" to @set INCLUDE=...
"C:\Program
Files\Microsoft Visual Studio 8\VC\PlatformSDK\Lib" to @set
LIB=...
"C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Bin"
to @set PATH=...
or if you kept the default Platform SDK
folder:
"C:\Program Files\Microsoft Platform SDK for Windows Server
2003 R2\Include" to @set INCLUDE=...
"C:\Program Files\Microsoft
Platform SDK for Windows Server 2003 R2\Lib" to @set LIB=...
"C:\Program Files\Microsoft Platform SDK for Windows Server 2003
R2\Bin" to @set PATH=...
- Download the "boost" library and "boost-jam"
package from
http://sourceforge.net/project/showfiles.php?group_id=7586
My
versions of files were "boost_1_33_1.exe" and
"boost-jam-3.1.13-1-ntx86.zip"
- Unzip the boost library to e.g.:
"C:\temp\boost_1_33_1"
- Extract bjam.exe from the boost-jam package to the
same directory i.e. "C:\temp\boost_1_33_1"
- Open a command window (go to
Start, run, type "cmd" and hit enter) and type
"cd
C:\temp\boost_1_33_1"
- type: << bjam.exe "-sVC80_ROOT=C:\Program
Files\Microsoft Visual Studio 8\VC" -sTOOLS=vc-8_0 install
>>
since it is better to use the compiler of Visual Studio
(called by the parameter vc-8_0) for
a boost utilization in Visual
Studio. You can add --prefix=C:\MyFolder\Boost\ if you want to install
it to another directory than "C:\boost\".
If Visual Studio
2005 had not been installed in the default folder i.e.
"C:\Program
Files\Microsoft Visual Studio 8\VC", change the folder accordingly.
You can disregard all the issued warnings (e.g. deprecated methods)
during the compilation.
If the process is successful, the final message
is something like "...updated 4889 targets...".
Once finished, all the
necessary files (.hpp .lib and .dll) for using boost are residing in
"C:\boost"
- Once the compilation is complete, move the "boost" up a
directory i.e. from
"C:\Boost\include\boost-1_33_1\boost" to
"C:\Boost\include\boost" by doing
a cut and paste. You can remove
the folder "boost-1_33_1" in "C:\Boost\include"
- In Visual C++, we need to
reference the boost library and the platform SDK.
Go to "Tools,
Options, Projects and Solutions, VC++ Directories, Show directories
for:"
In "Include Files", add: "C:\Boost\include" and "C:\Program
Files\Microsoft Platform SDK for Windows Server 2003 R2\Include"
In the
"Library Files", add "C:\Boost\lib" and "C:\Program Files\Microsoft Platform SDK
for Windows Server 2003 R2\Lib"
In the "Executable Files", add
"C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Bin". Close
Visual C++.
- Then we need to update the corewin_express.vsprops file in
order to make the Win32 template work in Visual C++ Express.
We need
to edit the corewin_express.vsprops file (found in "C:\Program Files\Microsoft
Visual Studio 8\VC\VCProjectDefaults\corewin_express.vsprops" )
and
change the string that reads: << AdditionalDependencies="kernel32.lib"
>> to
<< AdditionalDependencies="kernel32.lib user32.lib
gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib
oleaut32.lib uuid.lib" >>
- (facultative step) Then we can generate and
build a Win32 application to test
that our paths are set
correctly.
In Visual C++ Express, the Win32 Windows Application type is
disabled in the Win32 Application Wizard.
To enable that type, you
need to edit the file AppSettings.htm file located in the folder
“C:\Program Files\Microsoft Visual Studio
8\VC\VCWizards\AppWiz\Generic\Application\html\1033\AppSettings.htm".
In
a text editor (e.g. NotePad) comment out lines 441 - 444 by putting a // in
front of them as shown here:
// WIN_APP.disabled = true;
//
WIN_APP_LABEL.disabled = true;
// DLL_APP.disabled = true;
//
DLL_APP_LABEL.disabled = true;
Save and close the file and open Visual
C++ Express. From the File menu, click New Project.
In the New Project
dialog box, expand the Visual C++ node in the Product Types tree and
then click Win32. Click on the Win32 Console Application template and
then give your project
a name and click OK. In the Win32 Application
Wizard dialog box, make sure that Windows
application is selected as
the Application type and the ATL is not selected. Click the
Finish
button to generate the project. As a final step, test your project by clicking
the Start button in the IDE or by pressing F5. Your Win32 application
should build and
run. Close this project (in menu: File, Close
solution)
- Unzip Quantlib to a folder e.g. "C:\QuantLib\QuantLib-0.3.12"
- In Visual C++, do "File, Open Project" and open
"C:\QuantLib\QuantLib-0.3.12\QuantLib.sln" and
convert the file to the
VC++ 2005 format (The "QuantLib.dsw" is for VC++6)
- The library will be
faster if you switch the compiling from the debug configuration to the
release configuration. You can do so by going to "Build,
Configuration Manager" and choosing
"Release". The compiled library
will be more than ten times faster in Release than in Debug mode.
-
Select the "QuantLib" project (right click and Set as Start Up Project) and
build "QuantLib".
Then build the "testsuite" and then the rest.
-
Select "BermudanSwaption" and in order to run it, do "Start without Debugging"
or "Ctrl+F5"
- Now, you can enjoy ;-)
********************* USEFULL LINKS
**************************************
_____________________________________________________________________________
"This email and any files transmitted with it are confidential and intended solely for the individual(s) or entity named above and others who have been specifically authorized to receive it. If you are not the intended recipient, please do not read, copy, use or disclose the contents of this communication to others. Please notify the sender that you have received this e-mail in error by replying to the e-mail. Please then delete the e-mail and any copies of it. No reliance may be placed upon this email without written confirmation of its content and any liability arising from such reliance without written confirmation is hereby excluded." DEXIA Credit Local
_____________________________________________________________________________