How do I install the Linux library libc.so.6 [SOLVED]

How to fix library libc.so.6 not found error?

Libc is a C library. Libc6 and glibc are the same version of libc. Libc6 is version 6 of the linux C Library and version 2 of the GNU C Library Many applications on Linux need this library.

On Red Hat based systems, this library is called glibc, while on Debian base systems it is called libc6. In case this library is missing or not installed, then it possible you may face compilation related errors such as "library libc.so.6 not found or missing or no such file or directory"

Advertisement

There are 3 possible scenarios

  1. Library is not installed or missing
  2. The library path is not configured so the application is unable to locate the library file
  3. Library is installed for wrong ARCH i.e. your application may require 64-bit library but 32-bit library is installed

 

Scenario-1: How do I install the library libc.so.6?

Locate the package name of the library

First you need to know the package name required to install this library.

On Red Hat based systems you can use yum or dnf command. From the below output now you know the rpm responsible for installing 32-bit and 64-bit library.

~]# yum whatprovides */libc.so.6
glibc-2.28-151.el8.x86_64 : The GNU libc libraries
Repo        : @System
Matched from:
Filename    : /lib64/libc.so.6

glibc-2.28-164.el8.i686 : The GNU libc libraries
Repo        : baseos
Matched from:
Filename    : /lib/libc.so.6

glibc-2.28-164.el8.x86_64 : The GNU libc libraries
Repo        : baseos
Matched from:
Filename    : /lib64/libc.so.6

 

On Ubuntu based distributions, there are multiple command line options as shown below:

$ sudo dpkg -S libc.so.6
libc6:amd64: /lib/x86_64-linux-gnu/libc.so.6

Using apt-file command:

deepak@ubuntu:~$ sudo apt-file find libc.so.6
libc6: /lib/x86_64-linux-gnu/libc.so.6 
libc6-amd64-cross: /usr/x86_64-linux-gnu/lib/libc.so.6
libc6-amd64-i386-cross: /usr/i686-linux-gnu/lib64/libc.so.6
libc6-amd64-x32-cross: /usr/x86_64-linux-gnux32/lib64/libc.so.6
libc6-arm64-cross: /usr/aarch64-linux-gnu/lib/libc.so.6
libc6-armel-cross: /usr/arm-linux-gnueabi/lib/libc.so.6
......
libc6-x32-amd64-cross: /usr/x86_64-linux-gnu/libx32/libc.so.6
libc6-x32-cross: /usr/x86_64-linux-gnux32/lib/libc.so.6
libc6-x32-i386-cross: /usr/i686-linux-gnu/libx32/libc.so.6
libc6.1-alpha-cross: /usr/alpha-linux-gnu/lib/libc.so.6.1

or you can login to https://packages.ubuntu.com/ and search for your package:

Advertisement

How do I install the Linux library libc.so.6 [SOLVED]

 

Install the missing library on Red Hat Linux

Now that you know the package to be installed, go ahead and install it using package manager based on your distribution:

 

Installation for 64-bit

You can check the existence of the package on your system with the following command;

foc@fedora:~$ dnf list installed | grep glibc
glibc.x86_64                                      2.34-35.fc35                         @updates                                       
glibc-all-langpacks.x86_64                        2.34-35.fc35                         @updates                                       
glibc-common.x86_64                               2.34-35.fc35                         @updates                                       
glibc-devel.x86_64                                2.34-35.fc35                         @updates

If the package is not installed on your system, run the following commands in the terminal;

foc@fedora:~$ sudo dnf install glibc

The following command is sufficient to learn the location of the library after installation;

foc@fedora:~$ whereis libc.so.6
libc.so.6: /usr/lib64/libc.so.6

 

Installation for 32-bit

If your operating system is built on a 32 architecture or if the application you want to install requires 32 bit libraries, the following package should be installed;

foc@fedora:~$ sudo dnf install glibc.i686

Now let's look at the locations of the glibc library again;

foc@fedora:~$ whereis libc.so.6
libc.so.6: /usr/lib/libc.so.6 /usr/lib64/libc.so.6

Now since we installed both 32-bit and 64-bit version of the library so it can be found under both /usr/lib and /usr/lib64.
 

Install the missing library on Debian Linux

Installation for 64-bit

Package control is provided in Debian-based system with the following commands;

foc@foc:~$ dpkg -l | grep libc6
ii  libc6:amd64                 2.31-13+deb11u3                amd64        GNU C Library: Shared libraries
ii  libc6-dbg:amd64             2.31-13+deb11u3                amd64        GNU C Library: detached debugging symbols
ii  libc6-dev:amd64             2.31-13+deb11u3                amd64        GNU C Library: Development Libraries and Header Files

To install the 64-bit package;

foc@foc:~$ sudo apt install libc6

After this command, if the package is not installed, the installation starts with its dependencies.

To find out the location of the library, run the command below;

foc@foc:~$ whereis libc.so.6
libc.so: /usr/lib/x86_64-linux-gnu/libc.so /usr/lib/x86_64-linux-gnu/libc.so.6

 

Advertisement

Installation for 32-bit

To install the 32-bit package;

foc@foc:/$ sudo apt install libc6-i386

After package installation, the lib32 directory was created under the root directory (/);

foc@foc:/$ ls -la /lib32/libc.so.6 
lrwxrwxrwx 1 root root 12 Mar 18 00:37 /lib32/libc.so.6 -> libc-2.31.so

 

Scenario-2: Library is installed but LD_LIBRARY_PATH not configured

Many software packages look out for LD_LIBRARY_PATH environment variable to search for shared libraries. Many times you will just copy the required library path to /usr/lib or any other path but then your application will not start consuming the library just because the file is there.

We need to use ldconfig [options] lib_dirs which will update the ld.so cache file with shared libraries specified on the command line in lib_dirs, in trusted directories /usr/lib and /lib, and in the directories found in /etc/ld.so.conf.

Also Read: How to install shared libraries in Linux

 

Once you have copied your library file to /usr/lib then just execute

Advertisement
# ldconfig -n -v /usr/lib

ldconfig  creates  the  necessary links and cache to the most recent shared libraries found in the directories specified on the command line, in the file /etc/ld.so.conf, and in the trusted directories (/lib and /usr/lib).

Next you need to append this path to LD_LIBRARY_PATH variable:

For non-persistent changes you can use export command which will be applicable only for your terminal

# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib:/usr/local/lib

For permanent changes you can place the above command in .bash_profile of individual user or just create a file inside /etc/profile.d/set-library-path.sh and add the above command. You can use any file name, set-library-path.sh is just an example.

Also Read: Difference .bashrc vs .bash_profile (which one to use?)

 

Scenario-3: Proper library not installed as per your release version

It is possible that in your Linux box you are using both set of rpms i.e. 32-bit and 64-bit wherein the installed library package is 32-bit but your application package is looking for 64-bit library adn hence failing.

Advertisement

This I have already covered in Scenario-1 example on how to download and install packages for both 64-bit and 32-bit Linux environment.

 

Summary

We have explained the installation steps above. To remove packages, please pay attention to the following steps;

  • After the removal of i386 architecture packages, your applications with 32-bit library dependencies will be affected. Take this into consideration.
  • On a 64-bit architecture system, 32-bit libraries can cause confusion later, it is not recommended to install them. You should choose the 64-bit architecture compatible version of the application you want to use.
  • It is not recommended to uninstall these packages on a 64-architecture system. If you try to uninstall, you will encounter the following warning;
You are about to do something potentially harmful.
To continue type in the phrase 'Yes, do as I say!'
 ?]

Think twice before removing it.

 

Didn't find what you were looking for? Perform a quick search across GoLinuxCloud

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can either use the comments section or contact me form.

Thank You for your support!!

Leave a Comment

X