Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Static linking to lib and still requesting DLL

Using visual studio 2008, I have an .H and a .LIB file of a library. I wrote a program and referenced the LIB via the project properties. It compiles fine, but when it runs, it asks for the DLL to be installed. If the DLL is in the same dir as the EXE it works but, if I have the LIB, doesn't it already mean the functions are statically linked to my program?

like image 292
bahbah Avatar asked Feb 10 '10 22:02

bahbah


2 Answers

Not all lib files are static libraries. Some are import libraries, and chances are, that's what you linked with.

If your lib file is much smaller than its corresponding dll file, that's a sure sign that it's an import library.

like image 176
Chris Jester-Young Avatar answered Oct 15 '22 01:10

Chris Jester-Young


Letting your program use a DLL requires an import library. It is a file with the .lib extension, just like a static .lib. But it is very small, it only contains a list of the functions that are exported by the DLL. The linker needs this so it can embed the name of the DLL in the import table. You can see this for yourself by running Dumpbin.exe /imports on your .exe

like image 39
Hans Passant Avatar answered Oct 15 '22 01:10

Hans Passant