Home Linux Commandline Tips How to Check if a Library is 32-Bit or 64-Bit

How to Check if a Library is 32-Bit or 64-Bit

If you have managed to explore the software development ecosystem, then you are well aware of the implication a library has on a system. We can define a library as a grouping of non-volatile resources or an assortment of pre-compiled code blocks reusable to running programs. A program will therefore query a library for a resource it needs to continue with or finish its execution.

Libraries can either be 32-Bit or 64-bit depending on the availed Linux system architecture. A 64-bit Linux system can host both 32-bit and 64-bit libraries while a 32-bit Linux system can only host 32-bit libraries.

For this reason, this article will focus on 64-bit Linux system users. We should also note that the libraries being addressed in this article are C/C++ libraries due to their strong ties to the Linux operating system.

This article will help 64-bit Linux users determine whether they are using a 32-bit or 64-bit library on their Linux systems.

Types of Libraries

Different programs benefit from a single library because a library is simply a file with grouped pre-compiled code collections which are beneficial to multiple programs and can easily be referenced.

Under the Linux operating system environment, two types of libraries exist:

  • Static Libraries: These libraries have the file extension “.a” and are (at compile time) statically bound to a program.
  • Shared Libraries: These libraries have the file extension “.so”. They become active when a program launches and at runtime, they are loaded into memory.

A static library does not exist as an executable but as an archive of other files. On the other hand, a shared library is executable. For instance, ELF object files can be classified as static libraries while an ELF file can be regarded as a shared library.

Let us now look at the approaches to determining whether a library is a 64-bit Linux system is 32-bit or 64-bit.

Using Linux file Command

According to its man page, the file command is effective in determining file types. This attribute makes it ideal for determining the format of a library being used.

Let us run a format check on some libraries inside the /usr/lib directory.

$ ls -l /usr/lib 
List Linux Libraries
List Linux Libraries

To determine whether a library is a 64-bit or 32-bit, run:

$ file /usr/lib/klibc-K8e6DOmVI9JpyGMLR7qNe5iZeBk.so
Check if a Library is 32-Bit or 64-Bit
Check if a Library is 32-Bit or 64-Bit

The screen capture above confirms that the highlighted shared library is 64-bit.

We can also run a format check on the static library in the following manner:

$ file /usr/lib/x86_64-linux-gnu/libffi.a 
Find Type of File
Find Type of File

While dealing with a static library, the file command only reports it as an archive and doesn’t report whether it is a 64-bit or 32-bit library because it is not an ELF file.

Using Linux objdump Command

The objdump command references object files and dumps their related information on standard output. Its usage should be associated with the -f flag to display the file header information.

Let us use it to check the library format of a shared library:

$ objdump -f /usr/lib/klibc-K8e6DOmVI9JpyGMLR7qNe5iZeBk.so
Check Library Info in Linux
Check Library Info in Linux

The output portion “file format elf64” implies that we are using a 64-bit library.

Let us now use the objdump command to check the library format of a static library:

$ objdump -f /usr/lib/x86_64-linux-gnu/libffi.a
Check Static Library File Format
Check Static Library File Format

The objdump command goes through all the objects in the provided static library highlighting their associated file formats.

For a straightforward output, we can pipe the objdump command to an awk command in the following manner:

$ objdump -f /usr/lib/x86_64-linux-gnu/libffi.a | awk 'sub(/.*file format /,"") && !a[$0]++' 


We can now comfortably determine the used library format of both shared and static libraries on a Linux OS environment.

Ravi Saive
I am an Experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies. Founder of TecMint.com, LinuxShellTips.com, and Fossmint.com. Over 150+ million people visited my websites.

Each tutorial at UbuntuMint is created by a team of experienced writers so that it meets our high-quality standards.

Was this article helpful? Please add a comment to show your appreciation and support.

Got something to say? Join the discussion.

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.