Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a .lib file in a C# program

I have a header file and a .lib file created using C++.

Now I want to use it in a C# program. Is this possible?

like image 411
user2389323 Avatar asked Jul 25 '13 13:07

user2389323


People also ask

What is .LIB file in C?

For a static library, the . lib file contains obj files. Each obj file is the output of one and only one compiler source code input file. A lib file is just a collection of related obj files, much like putting obj files in a directory. That is essentially what a lib file is, a library of obj files.

How do I read a .LIB file?

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

What is the purpose of .LIB files?

LIB (lib.exe) creates standard libraries, import libraries, and export files you can use with LINK when building a program.


2 Answers

You can create a managed wrapper, see step by step instruction here:

http://tom-shelton.net/?p=95

like image 180
Dmitry Bychenko Avatar answered Oct 21 '22 17:10

Dmitry Bychenko


There's not a traditional linker to let you import the lib. Your best bet is to compile to a COM library and use interop to use it.

like image 31
Cj S. Avatar answered Oct 21 '22 19:10

Cj S.