So I have some .lib file (generated like this one) How to use it from my C# WPF application?
lib" extension for libraries and an ". obj" extension for object files. Some programs in the Unix environment such as lex and yacc generate C code that can be linked with the libl and liby libraries to create an executable.
Creating Libraries :: Static Library Setup First thing you must do is create your C source files containing any functions that will be used. Your library can contain multiple object files. After creating the C source files, compile the files into object files. This will create a static library called libname.
To load the LIB file, select File → Load Library..., navigate to the location of your LIB file, select the file, and click Open.
When you want to use native libraries from C# you won't need a .lib file. The way this is handled in .NET is by using Platform Invoke (P/Invoke). I suggest you follow the tutorial on MSDN, it will get you started:
Platform Invoke Tutorial
If you want to generate a wrapper you might want to have a look at the P/Invoke Interop Assistant on CodePlex. Please note that this tool works on the original C/C++ code. Using a .dll file to create a wrapper is not feasible because native DLLs don't store the signature of the exported functions (as described in this thread) and a lib file will store the signature in a compiler specific way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With