Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

know if .lib is static or import

Tags:

c++

c

windows

dll

I have .lib file compiled from C code. How I know if this self-contained static library or just an import lib and DLL will be needed at runtime? Is there some dumpbin option I'm missing?

like image 502
zaharpopov Avatar asked Jun 19 '11 13:06

zaharpopov


People also ask

Is .LIB a static library?

Examples of static libraries (libraries which are statically linked) are, . a files in Linux and . lib files in Windows.

How do I view 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 .LIB file contains?

lib file contains all the code and data for the library. The linker then identifies the bits it needs and puts them in the final executable. For a dynamic library, the . lib file contains a list of the exported functions and data elements from the library, and information about which DLL they came from.


2 Answers

Use the lib command. If it's static, lib will show you a pile of .obj files inside. Not so if it's am implib.

lib /list foo.lib 

will do it.

Also see:

https://docs.microsoft.com/en-us/cpp/build/reference/managing-a-library

like image 158
bmargulies Avatar answered Oct 13 '22 00:10

bmargulies


Look in its accompanying header files ,if the function are 'decorated' with __declspec(dllimport) that it's an import library. Or look for an accompanying .def file ,that also tells you that it's an import library.

like image 29
engf-010 Avatar answered Oct 12 '22 23:10

engf-010