Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use *.lib file in C# application?

Tags:

c#

.net

wpf

dll

.lib

So I have some .lib file (generated like this one) How to use it from my C# WPF application?

like image 617
Rella Avatar asked May 17 '10 10:05

Rella


People also ask

What is .LIB file in C?

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.

Can I create my own library in C?

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.

How do I open a .LIB file in Windows?

To load the LIB file, select File → Load Library..., navigate to the location of your LIB file, select the file, and click Open.


1 Answers

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.

like image 59
Dirk Vollmar Avatar answered Nov 02 '22 05:11

Dirk Vollmar