Click here to Skip to main content
15,917,176 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
How to use c++ static library in c# ?

The case scenario is:

1) I have a static library (a .lib file compiled from VC++).
2) I don't have the code of static library.
3) No any dll related to static library.
4) I have to call the functions from this static library into C# project.
5) There are hundreds of functions in the static library.

How to achieve this ?

Please give detailed steps.

(Note : I have gone thru many threads on this topic none of them answers this Q.)

Thanks in advance.
Posted
Updated 21-Feb-10 18:05pm
v3

The other option you have is to write managed C++ code that wraps the library, and can be called from C#. There's no automatic way to do it, you don't have a dll, you'll have to create one, managed will be easier, I reckon.
 
Share this answer
 
C# can call into C++ only using either a DLL or a COM component.

You will need to create a wrapper DLL that invokes the .LIB functions.
For each function in the .LIB file create and export a function in the DLL.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900