know if .lib is static or import
14,743
Solution 1
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
Solution 2
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.
Comments
-
zaharpopov almost 2 years
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 somedumpbin
option I'm missing? -
zaharpopov almost 13 yearscan you suggest which option(s) to give
lib
to perform this? I can't understand from its doc -
tom_mai78101 over 8 years@zaharpopov MSDN docs have been revamped since the release of Windows 8.1. Please check.
-
sean almost 7 yearsThere seems to be a similar way. Open the lib file with 7zip. If it's an imort lib, it would contain *.dll files. Otherwise, it would contain *.obj files, maybe in a folder.
-
truthadjustr about 5 yearsYour answer, in my opinion, is the better one. Thank you, i will adapt to your method. Before, I did it slightly differently: stackoverflow.com/questions/8019464/… but your
lib
method is the better method. -
zois almost 3 yearsTrying this today on Windows 10, I got
'lib' is not recognized as an internal or external command, operable program or batch file.
-
Nicholas Jela about 2 yearsthis is bad answer, please also let other know how to install
lib
command, since this command is not default avaible on any platform. -
Artem about 2 yearsWindows is only one platform, and this question is about windows, and the lib command comes with the windows SDK, which you need to have to do any development.
-
KcFnMi about 2 years
__declspec(dllimport)
is a thing of Microsoft compiler only afaik. -
Breno about 2 yearsIf you have Visual Studio installed, there is a lib.exe there, as well. If you install the Community edition, 2019, it will be somewhere like "C:\Program Files (x86)\ Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\##.##.#####\bin\Hostx64\x64\". The "##.##.#####" are a bunch of numbers, which I'm not sure what are... maybe a specific version? Plus, if you need the executable for 32 bit windows there are other folders there as well (e.g. Hostx32)