12

How could I tell one .lib file is a static library v.s. an import library for a DLL? Is there any tool or command that could do this?

Second question is how could I check the dependencies of a static library, I mean how could I know which DLLs are included in this static library?

Thanks for any help here.

Best regards,

cobe24
  • 211
  • 3
  • 8

2 Answers2

7

Import library will add a DLL dependency to your program. Your program won't start, if you don't have the DLL. (You may use Dependency Walker to get the names of the DLL's of your program depend on).

Afaik Static libraries do not have dependencies. They linked into the program, only linker errors will tell you if that particular library depends on another lib. (At least in GCC, I don't know want is the behaviors of the MS tools.)

Calmarius
  • 17,459
  • 16
  • 99
  • 146
  • To expand on this: link the static library with a trivial program, and then use Dependency Walker to look for any new DLL dependencies. – Harry Johnston Nov 05 '11 at 22:58
  • 4
    static libraries do typically have DLL dependencies for at least the basic system libraries (ntdll.dll, etc.) and may also have dependencies for the language runtime, e.g., msvcrt.dll. – Harry Johnston Nov 05 '11 at 23:02
4

Given only a wtf.lib file, the question is to determine wither this library file is a static library or an import library. The current way I do this is (via a combination of DOS prompt and a cygwin bash shell).

In DOS prompt needed to correctly run dumpbin.exe:

dumpbin -all wtf.lib > wtf.lib.txt

Then, in cygwin shell:

grep 'Archive member name' wtf.lib.txt

If the output of grep spits out a DLL filename, then wtf.lib is an import library. Else, it is a stand-alone static library.

eigenfield
  • 3,221
  • 1
  • 29
  • 32
  • 1
    I have to vow and admit to the more superior answer found here: https://stackoverflow.com/questions/6402586/know-if-lib-is-static-or-import – eigenfield Mar 29 '19 at 08:33