[CMake] static libs and more

David Cole david.cole at kitware.com
Thu Jul 17 17:03:02 EDT 2008


If you do...:
dumpbin /symbols mylib.lib

...then:
The output will contain "_IMPORT_DESCRIPTOR" if the .lib is an import
library for a .dll file.
It will (most likely) not contain this output if it is a static .lib file.

It's a heuristic as I'm pretty sure the static .lib file will contain that
output if you have, for example, a function named "PRINT_IMPORT_DESCRIPTOR"
in your library... But the absence of that string tells you that it is *not*
an import library for a .dll.

You could easily write a CMake macro that calls dumpbin with EXECUTE_PROCESS
and capture its output into a variable and analyze it.

(dumpbin.exe is usually available in the "VC\bin" directory of a Visual
Studio installation... easily accessible from a VC command prompt...)


HTH,
David


On Thu, Jul 17, 2008 at 4:09 PM, Philip Lowman <philip at yhbt.com> wrote:

>
>
>
> ...... Original Message .......
> On Thu, 17 Jul 2008 22:10:11 +0400 "Yuri Timenkov"
> <ytimenkov at parallels.com> wrote:
> >On Thursday 17 July 2008 23:00:15 Alin M Elena wrote:
> >The main problem AFAIK for VS is that static and dynamic libraries are
> >indistinguishable by extension. They both have a .lib one. And you don't
> know
> >in advance is some library is static one or just import library for some
> >dynamic one.
>
> I would be quite frankly amazed if someone couldn't write a 10-line CMake
> macro that can determine if a .LIB file is static or shared.  I wonder if
> simply keying on certain ASCII keywords in the .LIB file wouldn't be good
> enough (this would need some testing though, unless someone can find a
> detailed .LIB file specification).
>
> --
> Philip Lowman
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20080717/99fc87a7/attachment.htm>


More information about the CMake mailing list