Getting the architecture of a static library (.lib, .a) means reading the archive container first, then the object files inside it. On Windows, dumpbin /headers library.lib reports the machine type of each member; on Unix-like systems, file library.a and ar/nm/objdump -f give the format, member list, and object architecture in seconds. A library is a container, so treat "the library's architecture" as either the container format (COFF vs ELF vs Mach-O) or the per-object machine type (x64, x86, ARM64, armv7, and so on). They are related but not identical facts.
This article keeps the scope to static libraries and import libraries as they actually appear on disk. It covers the quickest universal checks first, then the tools that reveal detail, then the common traps that produce a wrong answer — mismatched aggregate reports, fat archives, mixed-architecture archives, and zero-member "stub" libraries.
The two questions hiding inside "what architecture is this lib?"
Before running any command, decide which question you need answered, because the same file can give different answers depending on what you inspect.
The first question is container architecture. This is the archive format itself: a Unix ar archive (ELF .a), a COFF/PE static library or import library (.lib), or a Mach-O static archive (.a on macOS). This answer tells you which toolchain family can consume the file at all.
The second is payload architecture. This is the machine type of every member object inside the archive: x64, x86, ARM64, ARM, MIPS, etc. This is the answer that usually matters, because a Windows .lib can contain 32-bit objects and still have a valid archive header.
A third, frequently decisive wrinkle: on Windows, an import library is technically a .lib too. It contains no code — only symbols that point at a DLL — so it is architecture-neutral or semi-neutral even when the DLL it describes is architecture-specific. If you run dumpbin /headers on a pure import library and the tool complains or shows no object headers, you are probably looking at import stubs, not object files. Verify with dumpbin /exports library.lib, which will list the imported symbols.
So the practical rule: identify the container, list its members, then classify each member's machine type. If all members agree, the whole library has that architecture. If they disagree, you have a mixed archive and need to treat "the architecture" as a set, not a single value.
Prerequisites: one file, one toolchain, one decision
You need only a shell and whatever inspection tools come with the compiler that produced or will consume the library. On Windows: dumpbin (Visual Studio), link, and optionally llvm-objdump/llvm-lib from the LLVM toolchain. On Unix-like systems: file, ar, nm, objdump, readelf where applicable. On macOS, Apple's file, ar, lipo, and otool/nm.
Have the exact file path, its originating build settings if available, and the target triple you intend to link against. A useful success check before starting: you can predict what the tool should say, and then confirm it. If the tool output contradicts your expectation, stop and inspect further rather than relinking blindly.
Step 1: Identify the container format without a compiler
The universal first move is file, on any operating system that ships it (including Windows when you have a Unix toolchain or Git Bash).
Typical output tells you the family immediately:
current ar archive or ar archive — a Unix archive; members are usually ELF objects. COFF archive or Microsoft COFF archive — a Windows static or import library. Mach-O archive — an Apple static archive. fat file / universal binary — a container holding several architectures.
On Windows without Unix tools, dumpbin /headers is the dependable first step for a .lib, and dumpbin /linkermember lists members without reading their headers. On macOS, file and lipo -info are the entry points.
Expected result and how to check success
After this step you should know the container family. Success check: the reported format matches the platform you expected. If you expected an ELF archive and get COFF archive, you have the wrong file or a cross-compiled artifact — do not proceed to link it; confirm the file came from the intended build.
A note on scope: a .lib with no Unix equivalent is not automatically COFF. Toolchains like MinGW/Linux cross builds can emit ar archives intended for Windows linkers, and LLVM's llvm-lib can produce COFF archives. Format and target are coupled but not identical, which is why the next step reads the members themselves.
Step 2: List members and read machine types
The container only tells you the wrapper. The machine type lives in each member's object header.
On Windows, the direct route:
Each member begins with a header section that says machine (x64), machine (x86), or machine (ARM64), followed by section and symbol tables. For many members the output is long; you are looking for the machine line and for any per-member inconsistency.
On Unix-like systems:
objdump -f on an archive prints a header block per member with architecture: and file format: fields, which makes it a strong single-command answer. ar t proves the archive parses and lists contents; nm proves symbols exist and identifies which members carry them. Some archives contain members in subdirectories or with long names, so ar t and nm -A together catch what a superficial listing misses.
On macOS:
What each command proves
| Command | Proves | Does not prove |
|---|---|---|
| file | Container family | Individual member architecture |
| ar t | Archive parses; member list | Machine type of members |
| dumpbin /headers | Machine type per COFF member | Which slices are link-compatible with your SDK |
| objdump -f | Format and architecture per member | Whether symbols are callable as intended |
| nm -A | Symbol presence and defining member | Compatibility with your linker's settings |
| lipo -info | Which architectures a fat archive holds | Whether only one slice is usable |
The pattern is deliberate: no single command is enough. Combine a container check, a member list, and a machine-type read; together they close the gaps.
Step 3: Confirm compatibility with a dry link or version check
Architecture readouts can be accurate and still not answer "will this link for my target?" The definitive test is a linker trial against a trivial consumer, using the exact toolchain and target you intend to ship.
On Windows with MSVC:
On Unix-like systems with GCC:
On macOS with clang:
Success means the linker resolves symbols and produces an output. Failure messages are diagnostic: machine type mismatch, LNK1112: module machine type 'x64' conflicts with target machine type 'x86', or is not the right architecture name the conflict directly. That error text is often better evidence than any header read, because it shows the two sides of the compatibility question.
When a dry link is not enough: version and runtime libraries
A successful link does not guarantee runtime compatibility. Static libraries built against a different C runtime (MSVC's /MT vs /MD, or different glibc versions) can link and still misbehave. This is a version/ABI question, not strictly an architecture question, but it sits inside the same decision, so verify the runtime setting when headers alone are ambiguous. On Unix, strings on a member, readelf --version-info, and nm on the archive can reveal expected symbol versions. Treat "link succeeded" as necessary, not sufficient.
Stop condition
If a dry link fails with a machine-type error after you have confirmed the target triple and the file is the one you meant to link, do not edit headers or hand-patch the archive. A mixed or wrongly built library needs a rebuild from the correct toolchain; escalate to whichever engineer owns the build or vendor SDK rather than patching binaries.
Step 4: Recognize import libraries and fat archives
Two special cases account for most wrong answers.
Import libraries. On Windows, dumpbin /headers sometimes errors or returns symbols with no object code for libraries that are really import stubs. Run dumpbin /exports library.lib; if you see imported function names and a DLL name, the library is an import library and its architecture tracks the DLL's, not the archive header's. A further check is dumpbin /dependents on the DLL itself, if you have it. Confirm the import library matches the DLL you will use at runtime.
Fat/universal archives. file reports fat file, or lipo -info lists multiple architectures. Here "the architecture" is plural. A build system must select the correct slice; if you see lipo -info list x86_64 arm64, the library is usable by both but your linker must pick one. lipo -thin arch can produce a single-architecture copy for testing, but treat that as a diagnostic, not a fix.
Mixed archives. Occasionally an archive contains objects of more than one machine type, usually from a bad merge or packaging step. No single-command header read will tell you this if it stops at the first member, so scan across members and flag inconsistency. Mixing object architectures in one library is generally not linkable as intended; treat it as a packaging bug.
Why the answer differs by platform: a brief look under the hood
A .a on Linux and a .lib on Windows are both archives, but the metadata is structured differently, which is why the tools differ.
An ar archive has a simple global header (!\n), a symbol index, and long-name tables; it does not carry a machine-type field of its own. Machine type lives in each ELF object header (e_machine field: EM_X86_64, EM_386, EM_AARCH64). That is why file and objdump -f read members, not the wrapper.
A COFF library is a Microsoft ar-style archive whose first linker-member points at an extended name table; each member is a COFF object with a Machine field (IMAGE_FILE_MACHINE_AMD64, IMAGE_FILE_MACHINE_I386, IMAGE_FILE_MACHINE_ARM64). Import members use different record structures (short import, long import) rather than full object code, which is why they look odd in dumpbin /headers.
Mach-O archives follow object headers with cputype/cpusubtype, and universal/fat wrappers put a table of slices at the front, each with an architecture and offset. lipo reads that table directly; this is why lipo -info is the right first answer on macOS and objdump -f is not.
The common thread: architecture is a property of members, never of the archive filename. The wrapper format only tells you which reader to reach for.
Common failures and what each means
These are the situations where the readout contradicts intuition, and what to do.
file says COFF archive but dumpbin /headers fails or finds no headers. Likely an import library or a library whose members are import records. Use dumpbin /exports; if imports appear, this is expected behavior, not corruption. Header read says x64 but the link fails on the target. Check the target you are linking for (32-bit project, ARM64 cross build); the header is telling you the object, not your settings. The error message names the conflict. One member says x86, another says x64. Mixed-architecture archive. Rebuild from consistent targets; do not attempt to link. ar t succeeds but nm finds no symbols. A stripped archive or a member list that does not match expectations. Confirm the file is the one you built, then check the build's strip step. file reports "data" or "executable" instead of archive. The file is not an archive at all: maybe a DLL renamed .lib, a response file, or a packaging artifact. Inspect with file and the toolchain's equivalent (dumpbin /headers on the DLL if one exists) before assuming it is a library. LLVM tools report a format the MSVC linker rejects, or vice versa. Cross-toolchain .lib files are not always interchangeable, and some LLVM archive variants differ in metadata details. Test with the exact linker that will consume the library; header compatibility is close to, but not identical with, link compatibility.
In each case the remedy is a check (export list, member list, or mismatch error), not a patch. Changing a header to match your target would produce a library that appears valid and fails at runtime.
A worked, reproducible example
To show the whole chain on a Windows-like setup with a Unix toolchain available, the sequence below is illustrative and uses generic names:
Interpretation: container is COFF; member demo.obj is x64 PE. If the project you will link into is x64, this is the right library; if it is x86, it is wrong and the error will name the conflict. On MSVC alone, the same result comes from:
For a fat archive, the corresponding read is:
and your build must choose one slice. A mixed archive would instead show a single member list whose per-member architecture fields disagree in objdump -f.
The arithmetic here is not numeric but logical: (1) confirm container, (2) list members, (3) confirm every member's machine type, (4) test with the consuming linker. If all four agree, the answer is settled; if step 3 disagrees with step 4, the linker error is correct and the header-level scan needs a second look at whether import records were misread as objects.
Practical rules for a clean verdict
Keep four checkpoints in mind and the ambiguity disappears quickly.
First, always name both the container and the member architecture when reporting a result; "it's x64" is incomplete without "COFF archive." Second, prefer the linker's own mismatch error over a header read when the two disagree, because the linker sees the actual compatibility constraint. Third, when lipo -info or file reports more than one architecture, treat the question as multiple-choice and make the build select a slice. Fourth, when a .lib has no visible object headers, check for import records before concluding the file is broken.
One more caution: a library reporting x64 under dumpbin can still contain x86 import stubs for a 32-bit DLL if it was assembled from mixed sources. The per-member scan across nm -A and objdump -f is the way to catch that, and the dry-link test with your real target is the final word. When the header says one thing and the link error says another, believe the error and rebuild the library from a single, correct target configuration. That is the only way to get a stable, reproducible answer rather than one that survives only until your next build.