Centos 5.11升级安装gcc5.3,傻瓜式安装脚本

环境

[bash][root@tiboo3 ~]# cat /etc/redhat-release
CentOS release 5.11 (Final)[/bash]

编译安装gcc

[bash]#!/bin/bash
GCC_V='5.3.0'
sudo yum install -y glibc-static libstdc++-static
wget http://ftp.gnu.org/gnu/gcc/gcc-${GCC_V}/gcc-${GCC_V}.tar.bz2 -O gcc-${GCC_V}.tar.bz2
tar jxvf gcc-${GCC_V}.tar.bz2
cd gcc-${GCC_V}
./contrib/download_prerequisites
cd ..
mkdir build_gcc${GCC_V}
cd build_gcc${GCC_V}
./gcc-${GCC_V}/configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
make -j8
sudo make install
cd ..
rm -rf build_gcc${GCC_V} gcc-${GCC_V} gcc-${GCC_V}.tar.bz2[/bash]

卸载旧版本

[bash]yum remove -y gcc
updatedb[/bash]

链接新版本

[bash]cd /usr/bin/
ln -s /usr/local/bin/g++ g++
ln -s /usr/local/bin/gcc gcc[/bash]

检查gcc版本

[bash][root@tiboo3 ~]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/5.3.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
Thread model: posix
gcc version 5.3.0 (GCC)[/bash]

后期源码编译安装.tar包的时候会出现

./configure: error: C compiler cc is not found

解决办法:
sudo ln -s /usr/local/bin/gcc /usr/bin/cc

您可以选择一种方式赞助本站

支付宝转账赞助

支付宝扫一扫赞助

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

图片 表情