摘要
在尝试运行asp.net core站点的时候,发现了gcc包版本太低,造成一些错误。没办法只能升级gcc了。
升级
最新包:http://gcc.parentingamerica.com/releases/gcc-6.2.0/gcc-6.2.0.tar.bz2
下载
wget http://gcc.parentingamerica.com/releases/gcc-6.2.0/gcc-6.2.0.tar.bz2
gcc
安装文件下载完成后,执行以下命令解压文件:
tar -xf gcc-6.2..tar.bz2
下载gcc依赖库和文件
解压完成后,执行以下命令进入工作目录:
cd gcc-6.2.
执行download_prerequisites
脚本,下载gcc
依赖文件和库:
./contrib/download_prerequisites
ownload_prerequisites
脚本,会下载安装gcc
所需的mpfr
、gmp
和mpc
文件。
[root@localhost gcc-6.2.]# ./contrib/download_prerequisites
---- ::-- ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2
=> “mpfr-2.4..tar.bz2”
Resolving gcc.gnu.org... 209.132.180.131
Connecting to gcc.gnu.org|209.132.180.131|:... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done. ==> PWD ... done.
==> TYPE I ... done. ==> CWD () /pub/gcc/infrastructure ... done.
==> SIZE mpfr-2.4..tar.bz2 ...
==> PASV ... done. ==> RETR mpfr-2.4..tar.bz2 ... done.
Length: (1.0M) (unauthoritative) %[==========================================================>] ,, .6K/s in 24s -- :: (44.3 KB/s) - “mpfr-2.4..tar.bz2” saved [] ---- ::-- ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2
=> “gmp-4.3..tar.bz2”
Resolving gcc.gnu.org... 209.132.180.131
Connecting to gcc.gnu.org|209.132.180.131|:... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done. ==> PWD ... done.
==> TYPE I ... done. ==> CWD () /pub/gcc/infrastructure ... done.
==> SIZE gmp-4.3..tar.bz2 ...
==> PASV ... done. ==> RETR gmp-4.3..tar.bz2 ... done.
Length: (1.8M) (unauthoritative) %[==========================================================>] ,, .5K/s in 92s -- :: (20.2 KB/s) - “gmp-4.3..tar.bz2” saved [] ---- ::-- ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz
=> “mpc-0.8..tar.gz”
Resolving gcc.gnu.org... 209.132.180.131
Connecting to gcc.gnu.org|209.132.180.131|:... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done. ==> PWD ... done.
==> TYPE I ... done. ==> CWD () /pub/gcc/infrastructure ... done.
==> SIZE mpc-0.8..tar.gz ...
==> PASV ... done. ==> RETR mpc-0.8..tar.gz ... done.
Length: (532K) (unauthoritative) %[==========================================================>] , .5K/s in 19s -- :: (27.7 KB/s) - “mpc-0.8..tar.gz” saved [] ---- ::-- ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.15.tar.bz2
=> “isl-0.15.tar.bz2”
Resolving gcc.gnu.org... 209.132.180.131
Connecting to gcc.gnu.org|209.132.180.131|:... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done. ==> PWD ... done.
==> TYPE I ... done. ==> CWD () /pub/gcc/infrastructure ... done.
==> SIZE isl-0.15.tar.bz2 ...
==> PASV ... done. ==> RETR isl-0.15.tar.bz2 ... done.
Length: (1.5M) (unauthoritative) %[==========================================================>] ,, .3K/s in 30s -- :: (51.4 KB/s) - “isl-0.15.tar.bz2” saved [] [root@localhost gcc-6.2.]#
下载安装过程
配置gcc
建立一个输出目录,编译时所有生成的中间文件都放到该目录下:
mkdir gcc-temp
工作目录切换至输出目录,并在其中执行配置和安装:
cd gcc-temp
执行configure
配置安装文件:
../configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
配置完成后,执行以下命令,编译gcc
:
make
编译过程较长,耐心等待。编译完成后,安装gcc
:
make install
安装完成后还需要替换系统默认的gcc
,执行以下命令,查找6.2
版本的安装文件:
ls /usr/local/bin | grep gcc
执行升级命令:
/usr/sbin/update-alternatives --install /usr/bin/gcc gcc /usr/local/bin/x86_64-pc-linux-gnu-gcc-6.2.
验证安装
查看版本号
gcc -v
到此说明安装成功了。
参考文章