centos下安装gcc

 

# 下载文件:
http://mirrors-usa.go-parts.com/gcc/releases/gcc-4.9.1/
$ wget -c http://www.netgull.com/gcc/releases/gcc-4.9.1/gcc-4.9.1.tar.gz

# 解压缩
$ tar -zxvf gcc-4.9.1.tar.gz

# 创建目录:编译目录和安装目录
$ cd gcc-4.9.1
$ mkdir build
$ mkdir /usr/local/gcc-4.9.1
$ mkdir /usr/local/gcc

#下载gmp,mpfr,mpc源码(可以不手动编译)
#通过自带脚本一键搞定。
$ ./contrib/download_prerequisites
# 也可以手动一个个下载源码包,解压后放在gcc源码目录下的gmp,mpfr,mpc子目录。

# 配置:选择安装目录以及编译的语言
$ cd build
$ ../configure   --prefix=/usr/local/gcc-4.9.1 --exec-prefix=/usr/local/gcc --enable-languages=c,c++ --with-mpc

# 编译
$ make # 如果 u 的 cpu 是四核的话,可以 make -j4 加速编译

# 安装
$ make install # 可能需要管理员权限

$ export PATH=/usr/local/gcc/bin:$PATH
$ ln -s /usr/local/gcc-4.9.1/include/c++/4.9.1 /usr/include/c++/4.9.1
$ export CPLUS_INCLUDE_PATH=/usr/include/c++/4.9.1:/usr/include/c++/4.9.1/x86_64-unknown-linux-gnu

Share

小 虾

哦也,我是小虾

You may also like...

1 Response

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.