CentOS 6.3 源码安装 GCC 4.8.2

1、安装 yum 依赖

sudo yum install gcc gcc-c++ glibc-static m4 -y

2、安装其他依赖 GMP, MPFR, MPC

# Tools/packages necessary for modifying GCC http://gcc.gnu.org/install/prerequisites.html

下载所需要的源码包

gmp-4.3.2.tar.bz2 (https://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2)

mpfr-2.4.2.tar.bz2 (https://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2)

mpc-0.8.1.tar.gz (https://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz)

gcc-4.8.2.tar.bz2 (https://gcc.gnu.org/pub/gcc/releases/gcc-4.8.2/gcc-4.8.2.tar.bz2)

# 安装依赖:(有序安装)

# gmp

tar jxf gmp-4.3.2.tar.bz2 && cd gmp-4.3.2 && mkdir build/ && cd build/ && ../configure --prefix=/usr/local/gcc/gmp-4.3.2 && sudo make && sudo make install

# mpfr

tar jxf mpfr-2.4.2.tar.bz2 && cd mpfr-2.4.2 && mkdir build/ && cd build && ../configure --prefix=/usr/local/gcc/mpfr-2.4.2 --with-gmp=/usr/local/gcc/gmp-4.3.2 && sudo make && sudo make install

# mpc

tar zxf mpc-0.8.1.tar.gz && cd mpc-0.8.1 && mkdir build/ && cd build/ && ../configure --prefix=/usr/local/gcc/mpc-0.8.1 --with-mpfr=/usr/local/gcc/mpfr-2.4.2 --with-gmp=/usr/local/gcc/gmp-4.3.2 && sudo make && sudo make install

# 以下很重要

# 添加共享库路径,sudo vi /etc/ld.so.conf ,添加如下内容到文件中,直接在文件后追加写入:

/usr/local/gcc/gmp-4.3.2/lib

/usr/local/gcc/mpfr-2.4.2/lib

/usr/local/gcc/mpc-0.8.1/lib

# 重要 保存退出,并执行 ldconfig 命令

ldconfig

3、安装 GCC 4.8.2 

# 安装

tar jxf gcc-4.8.2.tar.bz2 && cd gcc-4.8.2 && mkdir build && cd build && ../configure --prefix=/usr --enable-threads=posix --disable-checking --enable-languages=c,c++ --disable-multilib --with-gmp=/usr/local/gcc/gmp-4.3.2/ --with-mpfr=/usr/local/gcc/mpfr-2.4.2/ --with-mpc=/usr/local/gcc/mpc-0.8.1/ && sudo make && sudo make install

---
漫长等待~ 终于,安装成功!

----------------------------------------------------------------------
Libraries have been installed in:
/usr/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 for
more 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 `/home/work/gcc-4.8.2/build/x86_64-unknown-linux-gnu/libatomic'
make[3]: Leaving directory `/home/work/gcc-4.8.2/build/x86_64-unknown-linux-gnu/libatomic'
make[2]: Leaving directory `/home/work/gcc-4.8.2/build/x86_64-unknown-linux-gnu/libatomic'
make[1]: Leaving directory `/home/work/gcc-4.8.2/build'
[work@local build]$ gcc -v
使用内建 specs。
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-unknown-linux-gnu/4.8.2/lto-wrapper
目标:x86_64-unknown-linux-gnu
配置为:../configure --prefix=/usr --enable-threads=posix --disable-checking --enable-languages=c,c++ --disable-multilib --with-gmp=/usr/local/gcc/gmp-4.3.2/ --with-mpfr=/usr/local/gcc/mpfr-2.4.2/ --with-mpc=/usr/local/gcc/mpc-0.8.1/
线程模型:posix
gcc 版本 4.8.2 (GCC)

转载于:https://www.cnblogs.com/Primzahl/p/10481510.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值