PInvoke or using /clr:pure to compile

Posted by Yin Zhu on Stack Overflow See other posts from Stack Overflow or by Yin Zhu
Published on 2010-05-09T02:20:54Z Indexed on 2010/05/09 2:28 UTC
Read the original article Hit count: 351

Filed under:
|
|

I have a set of numerical libraries in C++ and I want to call them interactively in a interpretive language like F# or IronPython.

So I have two choices now:

  1. Compile the library in native DLL and use PInvoke to call functions in it.

  2. Compile the C++ library to .Net dll using visual c++ (/clr:pure compile option).

The advantage of 1 is that it is very fast, however there are more work in it, e.g. I cannot PInvoke double pointer (e.g. float **), I must write another wrapper in the C++ library to make the interface friendly to .Net.

The advantage of 2 is that I don't need to do know Mashaling strings, arrays, etc. However, the .net dll is slower compared to the native one.

What others factors should be considered when choosing between the two?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about pinvoke