So it would seem that the C# bindings for SWIG are available. One needs to browse the SVN repository or list of files on SouceForge to find them.
The SWIG folder contains several subfolders, depending on your language of choice, in my case C# was the one that interested me. You will need to download SWIG first and it the executable to system PATH
variable.
Make sure to read the Readme.txt
as it contains details about the QL_DIR
environment variable that also needs to be created.
This may be a limitation of VS Express - but the solution file contains both the C# project and C++ project, of which only either the C# or C++ portions can be opened at any time. My suggestion would be to created separate solution files for the C++ and the C# projects.
Coming from a .Net background, lib files, obj files and the all the other jazz associated with c++ takes some time to getting use to.
Steps taken to get a working C# library
- Download QuantLib and Boost as described here
- Download the tar ball of the QuantLib-SWIG folder from SourceForge. Edit: There is a download of the zip available on the home page. Its listed within the subfolders. Check the v1.0 folders under
Bindings
- Run the
swig.cmd
file located in QuantLib-SWIGCSharp
folder (you need to download SWIG first() --> this generates the cs wrapper files for Quantlib.
- Build the c++ project
NQuantLibc
- note the dll created here needs to be always shipped with the NQuantlib C# built dll. It needs to be placed in a location that is readable by the DLLImport
attribute. (See Dynamic-Link Library Search Order on MSDN for list of locations)
- Build the C# project
NQuantLib
With respect to my development environment, what would I need?
It seems that the current version of QuantLib only builds with VS 2008. There have been some changes to VS 2010 which causes some issues with compilation. The C# project builds fine, however just remember to change the Target Framework from v4 to v3.5 to lower.
Note: As the time of writing this there was an issue with the QL_HEX_VERSION
number in the source files of the C++ SWIG project. After running the swig.cmd
open the VS project, and change Line 344 of quantlib_wrap.cpp
to
#if QL_HEX_VERSION < 0x010001f0//0x010100f0
I have emailed the project author, and awaiting feedback. Edit: Luigi, correctly informed me that this is any issue with the code in SVN (which I used). He suggested that the QuantLib-SWIG-1.0.zip bindings should be used.
Quantlib also build on VC++ 2010 with the latest release.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…