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)

posted @ 2019-03-06 10:04  JeromePowell  阅读(519)  评论(0编辑  收藏  举报