C++ managed wrapper for static C library

  • Thread starter Thread starter jonlynch71
  • Start date Start date
J

jonlynch71

Hi,

I have a statically-linked C library (.lib) that I need to be able to
access from C#. I understand that the best way to do this is to code
a C++ managed wrapper.

How do I create this wrapper? One of the functions in this library is
as follows:

int *func2 (int *ary, int n, char *str)

How does this look in the wrapper?

Thanks,

Jon
 
Hi,

I have a statically-linked C library (.lib) that I need to be able to
access from C#. I understand that the best way to do this is to code
a C++ managed wrapper.

How do I create this wrapper? One of the functions in this library is
as follows:

int *func2 (int *ary, int n, char *str)

How does this look in the wrapper?

Thanks,

Jon

You don't need a managed wrapper, you only have to build a native DLL that exports the
functions you need to be public from the static lib.

Willy.
 
Wouldn't this then require the use of pinvoke in the c# code though?
I was hoping to avoid that if possible.

Thanks.
 
Wouldn't this then require the use of pinvoke in the c# code though?
I was hoping to avoid that if possible.

Thanks.

Sure it does require PInvoke, no big deal, you have to transition from managed code to
unmanaged code anyway.
Normally, you should only use a managed wrapper if you need to wrap an native C++ class, or
when you have to deal with a lot of native function calls.

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top