Re: Managed C++ and Quantlib

Posted by admin-216 on
URL: http://quantlib.414.s1.nabble.com/Managed-C-and-Quantlib-tp4126p4129.html

Ken and all,

Thanks for your examples and advice.

I'm glad someone is using this approach.

I'll try out the compiler settings provided below.

Cheers, Alex

> Alexander,
> My company did exactly what you are proposing.  We have a rather large
> C#/VB.Net application (managed code) that links to a Quantlib library
> (unmanaged code).  We use the option evaluation software for real time
> analytics.
> In short, it was a real pain due to the strange rules Microsoft has for
> mixing managed and unmanaged code.  However it was much less work than
> writing all the engines from scratch.
>
> We created two new projects.  The first I call QuantlibWrapper, which
> implements step (b) described below.  The second, I call
> CSharpTestDriver, which makes calls to the QuantlibWrapper code to prove
> it works.  The output of QuantlibWrapper is a dll, which any managed
> .Net project can access.
>
> I had to fool around a bit with the C/C++ flags and the Linker flags to
> get QuantlibWrapper to compile.  My notes are a little sketchy, but here
> they are:
> C/C++
>    General - Add include dir ..
>    Preprocessor - NOMINMAX
>    Language - /GR (enable run-time type info)
> Linker
>    Add include ..\lib
>   Output file ..\lib\QuantlibWrapper-VC71-gd-0_3_9.dll
>    Command Line - Remove \noentry
>    Input - remove nochkclr.obj (it generates warnings)
>
> I've attached the files I used to wrap the Day counters as an example.
> I hope this pattern will help you implement it for other classes.
>
> Good luck.
>
> Ken Goodhew
> Aspen Research Group, LTD.
>