I turned my C++ Dynamic link library into Static library just to acquire more knowledge. My question is how can I use the .obj file to compile both projects with C# express/MS visual studio?
5 Answers
No, you can't access static libraries directly from C#. You have to use a DLL.
6 Comments
Ivan Prodanov
I have to use a DLL,but Jon Skeet doesn't have to,he can compile anything. :) Thanks Jon.
Jon Skeet
@Radek: And how do you propose to then run the code? There may be ways of doing it if you're willing to use various unmanaged functions, but at that point you're barely using C# any more.
Jon Skeet
@Radek: I think for most practical purposes, saying "you can't do it" is accurate. How far does it have to go before you'd accept "you can't do it" - if you had to build your own CLR with extra hooks, would that count?
|
The way to "use" a static library in C# is to first create a Managed C++ wrapper that will provide a facade for the rest of the managed world. As everyone else has already commented, C# only supports DLLs for P/Invoke.
1 Comment
Ternary
Conceptually this makes sense but assume the static libs were third party and compiled with /MTd, how do you cross into /MDd land required for /CLI?