QuantLib-1.5 SWIG Patch for JVM/.NET

Update 23.11.2015: A modified version of the patch is now part of the official QuantLib Release 1.7.

Update 22.09.2015: Please find the latest and improved version of the patch for QuantLib 1.6.2 here.

The usage of QuantLib in JVM and .NET languages (e.g. Java/Scala and C#/F#) via the SWIG interface has a known shortcoming. The implementation of QuantLib’s observer pattern does not tolerate a parallel garbage collector running in a different thread. As a result programs are randomly crashing or producing “pure virtual function calls”. A detailed description of this problem can be found e.g. here and within the references.

Please find here a patch for QuantLib 1.5 to fix this issue.

Advertisement

5 thoughts on “QuantLib-1.5 SWIG Patch for JVM/.NET

  1. I tried to compile QuantLib V1.6.1 with the patch (boost_1_57_0). Having hard time building it.

    Do you plan to include this patch in the Github’s version any time soon?

    Following steps,
    – Copy Patch\QuantLib\ql\patterns files to QuantLibV1.6.1\ql\patterns
    – Copy (other than Patterns file) Patch\QuantLib\ql files to QuantLibV1.6.1\ql
    – Make following changes in boost_1_57_0/boost/smart_ptr/detail/sp_counted_impl.hpp
    #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)

    into

    #if defined(BOOST_SP_ENABLE_DEBUG_HOOKS_2)

    (Total 3 occurrences were changed)

    – Open QuantLib_VC10 solution at QuantLib-1.6.1
    – Include ql/patterns/observable.cpp to the solution
    – Include boost *lib* path and the QuantLib lib path in all the projects Project properties > Configuration Properties > Linker > General > Additional Library Directories
    it looks like ..\..\lib;C:\boost_1_57_0\libs;C:\QuantLib-1.6.1\lib;%(AdditionalLibraryDirectories)
    – Build Fails
    ***********************************************************************************************************
    Error 1 error C3861: ‘registerWithObservables’: identifier not found C:\QuantLib-1.6.1\ql\instruments\swaption.cpp 109 1 QuantLib
    Error 3 error LNK1181: cannot open input file ‘C:\QuantLib-1.6.1\lib\QuantLib-vc100-mt.lib’ C:\QuantLib-1.6.1\Examples\MarketModels\LINK MarketModels
    ***********************************************************************************************************

    Have not tried following (or I don’t need to build QuantLib 1.6 libary)?
    4. Add the full boost *lib* path and the QuantLib lib path in:
    Project properties > Configuration Properties > Linker
    > General > Additional Library Directories
    to your SWIG Visual Studio project, which compiles quantlib_wrap.cpp
    (Similar to what is needed to build the test suite.)
    5. build solution

    F:\OTC Live\TeamShare\QuantLib\boost_1_57_0;$(IncludePath)
    F:\OTC Live\TeamShare\QuantLib\boost_1_57_0\libs;$(LibraryPath)
    F:\OTC Live\TeamShare\QuantLib\QuantLib-1.6.1\QuantLib-1.6.1\lib

  2. Still can’t compile, there is something more to it – Have posted compilation errors in the Github link.

    Guess I need to make more changes?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s