By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,212 Members | 1,505 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,212 IT Pros & Developers. It's quick & easy.

C++ managed wrapper for static C library

P: n/a
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

Feb 5 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
<jo********@gmail.comwrote in message
news:11**********************@v33g2000cwv.googlegr oups.com...
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.

Feb 5 '07 #2

P: n/a

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

Thanks.

Feb 5 '07 #3

P: n/a
<jo********@gmail.comwrote in message
news:11**********************@p10g2000cwp.googlegr oups.com...
>
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.


Feb 6 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.