源码编译安装gcc-5.2.0方法
首先到官网下载最新版本gcc:https://gcc.gnu.org/
(好家伙,一百多M)本地下载:百度网盘
准备开始:
1:解压,进入gcc目录
> tar -zxvf gcc-5.2.0.tar.gz
> cd gcc-5.2.0
2:安装依赖
> ./contrib/download_prerequisites
#会自动安装mpfr-2.4.2,gmp-4.3.2,mpc-0.8.1,isl-0.14
3:配置选项
> ./configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
4:编译
> make -j4
#j后面的数字可根据cpu的核心数来做调整,可以更快的编译。编译时间一般比较长,你可以约个妹子去喝杯咖啡聊聊天😄👯
5:安装
> sudo make install
#安装完成后测试
> gcc -v
使用内建 specs。
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/5.2.0/lto-wrapper
目标:x86_64-unknown-linux-gnu
配置为:./configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
线程模型:posix
gcc 版本 5.2.0 (GCC)
安装完成。
如果出现类似提示:
/usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21′ not found
/usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15′ not found
/usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.20′ not found
等等……需要更新动态链接库
#提示:最好备份原始链接库
#/usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6.*
> sudo cp /usr/local/lib64/libstdc++.so.6.0.21 /usr/lib64/libstdc++.so.6.0.21
> sudo rm -r /usr/lib64/libstdc++.so.6
> sudo ln -S /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6.0.21
yum安装gcc
yum install gcc-c++
yum install gcc-g77
yum install flex autoconf zlib curl zlib-devel curl-devel bzip2 bzip2-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel
以下是在本地的28主机上执行的结果
yum install gcc-c++
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
gcc-c++ i386 4.1.2-44.el5 base 3.4 M
Installing for dependencies:
gcc i386 4.1.2-44.el5 base 5.2 M
glibc-devel i386 2.5-34.el5_3.1 updates 2.0 M
glibc-headers i386 2.5-34.el5_3.1 updates 598 k
kernel-headers i386 2.6.18-164.el5 updates 993 k
libgomp i386 4.3.2-7.el5 base 67 k
libstdc++-devel i386 4.1.2-44.el5 base 2.9 M
Updating for dependencies:
cpp i386 4.1.2-44.el5 base 2.7 M
glibc i686 2.5-34.el5_3.1 updates 5.2 M
glibc-common i386 2.5-34.el5_3.1 updates 16 M
libgcc i386 4.1.2-44.el5 base 94 k
libstdc++ i386 4.1.2-44.el5 base 363 k
Transaction Summary
=============================================================================
Install 7 Package(s)
Update 5 Package(s)
Remove 0 Package(s)
Total download size: 40 M
yum install gcc-g77
Nothing to do
yum install flex autoconf zlib curl zlib-devel curl-devel bzip2 bzip2-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
autoconf noarch 2.59-12 base 647 k
bzip2-devel i386 1.0.3-4.el5_2 base 38 k
curl-devel i386 7.15.5-2.1.el5_3.5 updates 307 k
flex i386 2.5.4a-41.fc6 base 124 k
freetype-devel i386 2.2.1-21.el5_3 updates 146 k
libjpeg-devel i386 6b-37 base 105 k
libpng-devel i386 2:1.2.10-7.1.el5_3.2 updates 181 k
libtiff-devel i386 3.8.2-7.el5_3.4 updates 465 k
ncurses-devel i386 5.5-24.20060715 base 1.6 M
pam-devel i386 0.99.6.2-4.el5 base 186 k
zlib-devel i386 1.2.3-3 base 101 k
Updating:
bzip2 i386 1.0.3-4.el5_2 base 48 k
curl i386 7.15.5-2.1.el5_3.5 updates 232 k
Installing for dependencies:
e2fsprogs-devel i386 1.39-20.el5 base 572 k
imake i386 1.0.2-3 base 319 k
keyutils-libs-devel i386 1.2-1.el5 base 27 k
krb5-devel i386 1.6.1-31.el5_3.3 updates 1.8 M
libidn-devel i386 0.6.5-1.1 base 239 k
libselinux-devel i386 1.33.4-5.1.el5 base 143 k
libsepol-devel i386 1.15.2-1.el5 base 189 k
openssl-devel i386 0.9.8e-12.el5 updates 1.9 M
Updating for dependencies:
audit i386 1.7.7-6.el5_3.3 updates 365 k
audit-libs i386 1.7.7-6.el5_3.3 updates 77 k
audit-libs-python i386 1.7.7-6.el5_3.3 updates 77 k
e2fsprogs i386 1.39-20.el5 base 967 k
e2fsprogs-libs i386 1.39-20.el5 base 118 k
freetype i386 2.2.1-21.el5_3 updates 310 k
krb5-libs i386 1.6.1-31.el5_3.3 updates 660 k
krb5-workstation i386 1.6.1-31.el5_3.3 updates 869 k
libpng i386 2:1.2.10-7.1.el5_3.2 updates 241 k
libselinux i386 1.33.4-5.1.el5 base 76 k
libselinux-python i386 1.33.4-5.1.el5 base 58 k
libtiff i386 3.8.2-7.el5_3.4 updates 306 k
openssl i686 0.9.8e-12.el5 updates 1.4 M
pam i386 0.99.6.2-4.el5 base 965 k
Transaction Summary
=============================================================================
Install 19 Package(s)
Update 16 Package(s)
Remove 0 Package(s)
Total download size: 16 M
三次yum就行了。
对yum 的理解 会自动检测 和安装