Can I link quantlib lib to C++/CLI?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Can I link quantlib lib to C++/CLI?

Cliffy
Hi folks,

If I want to develope my application in .net and use quantlib C++, can I link my C++/CLI project to quantlib lib?

I tried to created a C++ CRL console application and cut and paste a few lines of codes from swap example,

#include <ql/quantlib.hpp>
#include <boost/timer.hpp>
#include <iostream>
#include <iomanip>
using namespace QuantLib;
using namespace System;
int main(array<System::String ^> ^args)
{
            boost::timer timer;
           std::cout << std::endl;
           Calendar calendar = TARGET();
           Date settlementDate(22, September, 2004);
           retuen 1;
}

with a little bit tweaks, the program compiles and run fine and I can see settlementDate pouplated correctly. (VS 2005)

Now when I copy and paste the whole swapvaluation.cpp, it compiles fine but behaves differently than when it runs in unmanaged environment. The codes exits because there is some errors caught.

I got this ideas from reading some posts in Wilmotts forum but I am not sure I understand it correclty, can someone gives me some thoughts? Am I totally wrong that I just straight out can not do this and why?

Thanks and Happy New Year!

Cliffy

Reply | Threaded
Open this post in threaded view
|

Re: Can I link quantlib lib to C++/CLI?

Cliffy
ok, should've done a search earlier,

need to change singleton.cpp

inline T& Singleton<T>::instance() {

seems to be working now, thanks,

Cliffy

Cliffy wrote
Hi folks,

If I want to develope my application in .net and use quantlib C++, can I link my C++/CLI project to quantlib lib?

I tried to created a C++ CRL console application and cut and paste a few lines of codes from swap example,

#include <ql/quantlib.hpp>
#include <boost/timer.hpp>
#include <iostream>
#include <iomanip>
using namespace QuantLib;
using namespace System;
int main(array<System::String ^> ^args)
{
            boost::timer timer;
           std::cout << std::endl;
           Calendar calendar = TARGET();
           Date settlementDate(22, September, 2004);
           retuen 1;
}

with a little bit tweaks, the program compiles and run fine and I can see settlementDate pouplated correctly. (VS 2005)

Now when I copy and paste the whole swapvaluation.cpp, it compiles fine but behaves differently than when it runs in unmanaged environment. The codes exits because there is some errors caught.

I got this ideas from reading some posts in Wilmotts forum but I am not sure I understand it correclty, can someone gives me some thoughts? Am I totally wrong that I just straight out can not do this and why?

Thanks and Happy New Year!

Cliffy