Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determining the CPU architecture of a static library (LIB) on Windows

I just built libpng on a 64-bit Windows machine using VS2008. It produces a libpng.lib file inside the \projects\visualc71\Win32_Lib_Release directory (Configuration used being "LIB Release").

I used dumpbin to inspect this LIB file:

C:\Temp\libpng-1.4.3>dumpbin projects\visualc71\Win32_LIB_Release\libpng.lib Microsoft (R) COFF/PE Dumper Version 9.00.30729.01 Copyright (C) Microsoft Corporation.  All rights reserved.   Dump of file projects\visualc71\Win32_LIB_Release\libpng.lib  File Type: LIBRARY    Summary           8E4 .debug$S          DF2 .drectve         2BCD .rdata        21165 .text  C:\Temp\libpng-1.4.3> 

It does not however show the architecture of the LIB file. How do I find if a given LIB file is built for 32-bit or 64-bit architecture?

like image 880
Sridhar Ratnakumar Avatar asked Jul 23 '10 21:07

Sridhar Ratnakumar


People also ask

Are Lib files static?

Static Linking creates larger binary files, and need more space on disk and main memory. Examples of static libraries (libraries which are statically linked) are, . a files in Linux and . lib files in Windows.

How do I read 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 does .LIB contain?

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.

What are .LIB files in Windows?

LIB (lib.exe) creates standard libraries, import libraries, and export files you can use with LINK when building a program. LIB runs from a command prompt. You can use LIB in the following modes: Building or modifying a COFF library.


1 Answers

Use dumpbin /headers

The machine type is almost the first line you'll get.

It will be 14c for x86 and 8664 for x64

n:>dumpbin lib642.lib /headers

Microsoft (R) COFF/PE Dumper Version
10.00.30319.01 Copyright (C) Microsoft Corporation. All rights reserved.

Dump of file lib642.lib

File Type: LIBRARY

FILE HEADER VALUES 8664 machine (x64

Or

n:>dumpbin Lib32.lib /headers

Microsoft (R) COFF/PE Dumper Version
10.00.30319.01 Copyright (C) Microsoft Corporation. All rights reserved.

Dump of file Lib32.lib

File Type: LIBRARY

FILE HEADER VALUES 14C machine (x86)

like image 191
Will Dean Avatar answered Oct 14 '22 00:10

Will Dean