C# Problem (compatible with C++)

  • Thread starter Thread starter alan
  • Start date Start date
A

alan

Hi All,

I am a newbie in C#.

I have a several question want to throw out.

1) How can I include a C/C++ library into C# ? any samples?
2) If I have *.LIB library file (from C/C++), how can I use it on C#?
3) I wrote some C/C++ customized functions and save it on CPP
file(*.cpp) , how can I reuse it on C#?

Please help.
Thank you very much.
 
Inline ***

Willy.

alan said:
Hi All,

I am a newbie in C#.

I have a several question want to throw out.

1) How can I include a C/C++ library into C# ? any samples?
*** You can't include a C/C++ library in C#, at best you can call exported C
style functions (assuming your library is effectively a DLL) using PInvoke
interop.
2) If I have *.LIB library file (from C/C++), how can I use it on C#?
*** You can't, LIB can only be statically linked, one option is to build a
dll from your lib, another is to wrap your calls to your lib functions in a
DLL and export the wrappers.
3) I wrote some C/C++ customized functions and save it on CPP
file(*.cpp) , how can I reuse it on C#?
*** You can't. C# is not C/C++ you can't mix both on source level.
What you can do is:
- build a DLL from your C/C++ code and export the functions.
- or use Managed C++ to build managed code wrappers for your unmanaged C/C++
code.
 
Back
Top