Centos6.9升级glibc到 2.17版
升级gcc到4.9.4
当前版本:# gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23)
Copyright © 2010 Free Software Foundation, Inc.
本程序是自由软件;请参看源代码的版权声明。本软件没有任何担保;
包括没有适销性和某一专用目的下的适用性担保。
wget http://ftp.gnu.org/gnu/gcc/gcc-4.9.4/gcc-4.9.4.tar.bz2
tar -jxvf gcc-4.9.4.tar.bz2
cd gcc-4.9.4
mkdir build-gcc-4.9.4
./contrib/download_prerequisites ##下载编译所必需的插件和文件
####下载完成后进行编译安装####
cd build-gcc-4.9.4/
…/configure -enable-checking=release -enable-languages=c,c++ -disable-multilib ###配置编译参数
make -j4 ##需要等待一段时间,这里如果server性能足够,可以-j9
echo $? #为0则继续,出现错误, 则需要排错重新make
make install
####安装完成后,check####
[root@localhost src]# gcc --version
gcc (GCC) 4.9.4
Copyright © 2015 Free Software Foundation, Inc.
报错
ldconfig: /usr/local/lib/…/lib64/libstdc++.so.6.0.20-gdb.py is not an ELF file - it has the wrong magic bytes at the start.
Libraries have been installed in:
/usr/local/lib/…/lib64
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR’
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH’ environment variable
during execution - add LIBDIR to the `LD_RUN_PATH’ environment variable
during linking - use the `-Wl,-rpath -Wl,LIBDIR’ linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf’
See any operating system documentation about shared libraries formore information, such as the ld(1) and ld.so(8) manual pages.
make[4]: Nothing to be done for install-data-am'. make[4]: Leaving directory
/data/backup/filestore/gcc-4.9.4/build-gcc-4.9.4/x86_64-unknown-linux-gnu/libatomic’
make[3]: Leaving directory /data/backup/filestore/gcc-4.9.4/build-gcc-4.9.4/x86_64-unknown-linux-gnu/libatomic' make[2]: Leaving directory
/data/backup/filestore/gcc-4.9.4/build-gcc-4.9.4/x86_64-unknown-linux-gnu/libatomic’
make[1]: Leaving directory `/data/backup/filestore/gcc-4.9.4/build-gcc-4.9.4‘
处理
新建文件,指定gcc放置路径,重新make install
cat /etc/ld.so.conf.d/local.conf
/data/backup/filestore/gcc-4.9.4/build-gcc-4.9.4/
简单的办法是在 /etc/ld.so.conf.d 下新建一个文件 local.conf,里边写上 /usr/local/lib。然后以 root 权限执行 ldconfig。这样你的系统才会找得到安装到 /usr/local/lib 下的库文件。
升级glibc
]# ldd --version
ldd (GNU libc) 2.12
Copyright © 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
由 Roland McGrath 和 Ulrich Drepper 编写。
操作
wget http://ftp.gnu.org/gnu/glibc/glibc-2.17.tar.gz
tar zxvf glibc-2.17.tar.gz
cd glibc-2.17
mkdir build
cd build/
…/configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
make -j4
make install
验证结果 # ldd --version
ldd (GNU libc) 2.17
Copyright © 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
由 Roland McGrath 和 Ulrich Drepper 编写。