62

I want to install Android NDK on my CentOS 6.5 machine. But when I ran the program, it says it needs glibc 2.14 to be able to run. My CentOS 6.5 only has Glibc 2.12 installed. So I tried to update glibc by:

$ sudo yum update glibc

But after that I found the glibc version is still 2.12, not 2.14.

$ ldd --version
ldd (GNU libc) 2.12

I think glibc 2.14 may not be available on CentOS repositories. So how can I update it to glibc 2.14 on CentOS 6.5?

tonga
  • 801
  • 2
  • 9
  • 6
  • 2
    It's easier to upgrade to CentOS7 which contains GLibC 2.14 than it is to upgrade GLibC from 2.12 to 2.14. See [Skype Call Recorder](http://unix.stackexchange.com/questions/176464/skype-call-recorder-in-debian-7-1-lib-x86-64-linux-gnu-libc-so-6-error) – eyoung100 Dec 29 '14 at 20:34
  • @eyoung100 I still need CentOS 6.5 rather than 7. Is there an easy way to upgrade Glibc to 2.14? Thx! – tonga Dec 29 '14 at 20:45
  • 3
    No, see [one of my other answers for why](http://unix.stackexchange.com/questions/152258/using-awesome-window-manager-on-centos-7/152809#152809). – eyoung100 Dec 29 '14 at 20:51
  • Based on your answers, it seems that the best solution will be either upgrading to CentOS 7 or using an older version of NDK which requires glibc 2.12. Thanks for your comments. – tonga Dec 29 '14 at 21:01
  • 1
    You could also install a CentOS7 chroot to run the NDK in. – derobert Dec 29 '14 at 21:23
  • Not glibc-2.14 but glibc-2.17 and working good on CentOS 6.10: https://gist.github.com/harv/f86690fcad94f655906ee9e37c85b174 – velop Nov 14 '19 at 08:38

3 Answers3

90

You cannot update glibc on Centos 6 safely. However you can install 2.14 alongside 2.12 easily, then use it to compile projects etc. Here is how:

mkdir ~/glibc_install; cd ~/glibc_install 

wget http://ftp.gnu.org/gnu/glibc/glibc-2.14.tar.gz

tar zxvf glibc-2.14.tar.gz

cd glibc-2.14

mkdir build

cd build

../configure --prefix=/opt/glibc-2.14

make -j4

sudo make install

export LD_LIBRARY_PATH="/opt/glibc-2.14/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
roaima
  • 107,089
  • 14
  • 139
  • 261
UnitasBrooks
  • 1,002
  • 7
  • 8
  • 4
    Want to mention, that builing process takes 2.5 hours on slow AWS. Maybe useful for someone the next info: instruction above fixes `psycopg2` issue `ImportError: /lib/libc.so.6: version 'GLIBC_2.14'` (I use Centos 6.5 and PostgreSQL v 9.6) – TitanFighter Nov 08 '16 at 02:54
  • 1
    Brilliant answer! I followed this answer exactly and it worked like a charm. Thank you – thonnor Sep 21 '17 at 15:28
  • 5
    Can also be used for later versions; simply change "2.14" to "2.23" or whatever version you need, as highlighted by things like: `/usr/local/lib/somlelib.so: undefined reference to 'somefunction@GLIBC_2.23'` (the last few digits are the version). To make the compile faster, use make -j8 if you have 8 threads on your cpu etc. Mine completed in few minutes. – Roel Van de Paar Feb 19 '18 at 09:09
  • I'm left with `relocation error: libc.so.6: symbol _dl_find_dso_for_object, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference` after the export phase (when trying any command). Can anyone help? @Roel – belka Mar 24 '18 at 07:00
  • 1
    Thanks man, worked as expected on `CENTOS 6.10`. I replaced this line `sudo make install` with `make install` while I was root, because my user was not in the sudoers file – Accountant م Apr 16 '19 at 20:51
  • 2
    Beware that setting `LD_LIBRARY_PATH` comes with its own *host* of problems. It’s not an ideal solution by a long shot. – Konrad Rudolph Apr 23 '19 at 13:07
  • I had an error about selinux not being able to find `libaudit.h`, and a search found that using `--without-selinux` on the `configure` command fixes it. – Matt Kerr Aug 13 '20 at 22:30
  • also had an error about `Can't open configuration file /opt/glibc-2.14/etc/ld.so.conf: No such file or directory` i did a touch on this file to get past it – Matt Kerr Aug 13 '20 at 23:49
  • 1
    To set the timezone for the new gclib: `ln -s /usr/share/zoneinfo/Europe/Rome /usr/glibc/etc/localtime` as it won’t use your system timezone. Check with: `/opt/glibc-2.14/lib/ld-2.14.so --library-path "/opt/glibc-2.14/lib:/lib64" /bin/date` – Marco Marsala Mar 18 '21 at 16:11
  • Are the commands the same when building on Arm (armv7l)? I am having difficulties. – Danijel May 20 '22 at 17:35
9

To install glibc 2.14 in parallel, add the configure prefix:

tar zxvf glibc-2.14.tar.gz
cd glibc-2.14
mkdir build
cd build
../configure --prefix=/opt/glibc-2.14
make -j4
make install

Following this process, you'll be able to build 2.14 but you will need to tell the compiler where to look for glibc.

Below are the ways you can expose the glibc to your program.

  1. LD_LIBRARY_PATH=/opt/glibc-2.14/lib

    export LD_LIBRARY_PATH.

    The library is exposed during your current login session.

  2. You can permanently link your new glibc version like so, but please read the WARNING below:

    ln -sf /opt/glibc-2.14/glibc-2.14.so /lib/libc.so.6.

Since libc.so.6 is just a symbolic link. Executing the above command will make the link point towards the new glibc library. However this step is not recommended since there are many programs in Linux which depend on older versions and will stop working.

UnitasBrooks
  • 1,002
  • 7
  • 8
mikel
  • 91
  • 1
  • 4
  • 3
    Be extremely careful changing the sym link, you can end up breaking a lot of things if you create a wrong sym link. – jhnlsn Nov 22 '21 at 23:09
1

Common alternative technique. Installing GLIBC 2.14 in parallel (Intall it to the /opt directory) Then it is available to the programs which require it without breaking your core OS.