CentOS 6.3 源碼安裝 GCC 4.8.2

一、安裝 yum 依賴html

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

二、安裝其餘依賴 GMP, MPFR, MPCc++

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

下載所須要的源碼包ui

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

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

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)orm

# 安裝依賴:(有序安裝)htm

# 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

三、安裝 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)

相關文章
相關標籤/搜索