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?
Asked
Active
Viewed 3,782 times
8

Micha Wiedenmann
- 19,979
- 21
- 92
- 137

bahbah
- 83
- 1
- 3
-
check http://stackoverflow.com/questions/3573475/how-does-the-import-library-work-details – Wakan Tanka Sep 08 '16 at 22:56
2 Answers
17
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.

C. K. Young
- 219,335
- 46
- 382
- 435
-
4You can also run `dumpbin /exports` on the .lib file and if you end up with a list of all the functions in the library, it's an import lib. – Michael Burr Feb 11 '10 at 01:41
-
5`lib /list` is also useful. If you only see `.obj` references, then it is only static. If it only has `.dll` then it is an import only library. Note: that it is possible for a `.lib` file to be both. – docwhat Nov 16 '10 at 15:23
11
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

Hans Passant
- 922,412
- 146
- 1,693
- 2,536