http://blog.csdn.net/q229827701/article/details/51492833
1.资源准备
gcc-4.8.5.tar.gz,
然后可能用到的有
gmp-4.3.2.tar.bz2,mpfr-3.1.4.tar.bz,mpc-1.0.3.tar.gz,
中途用到的依赖库可能会有
autogen-5.16.2.tar.gz
2.安装顺序
./configure &&make &&make install
安装mpfr./configure --with-gmp=/usr/local/gmp-4.3.2 &&make&&make check&&make install
安装mac./configure --with-gmp=/usr/local/gmp-4.3.2 --with-mpfr=/usr/local/mpfr-3.1.4&&make&&make check&&make install
[root@ximena gcc-4.8.5]# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/usr/local/mpc-1.0.3/lib:/usr/local/gmp-4.3.2/lib:/usr/local/mpfr-3.1.4/lib
[root@ximena gcc-4.8.5]# ./configure --prefix=/usr/local/gcc-4.8.5 --with-gmp=/usr/local/gmp-4.3.2 --with-mpfr=/usr/local/mpfr-3.1.4 --with-mpc=/usr/local/mpc-1.0.3&&make&&make install
gcc安装时间比较长,如果没有意外的话,出现下面的界面,则说明安装成功libtool: install: /usr/bin/install -c .libs/libatomic.so.1.0.0 /usr/local/gcc-4.8.5/lib/../lib64/libatomic.so.1.0.0
libtool: install: (cd /usr/local/gcc-4.8.5/lib/../lib64 && { ln -s -f libatomic.so.1.0.0 libatomic.so.1 || { rm -f libatomic.so.1 && ln -s libatomic.so.1.0.0 libatomic.so.1; }; })
libtool: install: (cd /usr/local/gcc-4.8.5/lib/../lib64 && { ln -s -f libatomic.so.1.0.0 libatomic.so || { rm -f libatomic.so && ln -s libatomic.so.1.0.0 libatomic.so; }; })
libtool: install: /usr/bin/install -c .libs/libatomic.lai /usr/local/gcc-4.8.5/lib/../lib64/libatomic.la
libtool: install: /usr/bin/install -c .libs/libatomic.a /usr/local/gcc-4.8.5/lib/../lib64/libatomic.a
libtool: install: chmod 644 /usr/local/gcc-4.8.5/lib/../lib64/libatomic.a
libtool: install: ranlib /usr/local/gcc-4.8.5/lib/../lib64/libatomic.a
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/sbin" ldconfig -n /usr/local/gcc-4.8.5/lib/../lib64
ldconfig: /usr/local/gcc-4.8.5/lib/../lib64/libstdc++.so.6.0.19-gdb.py is not an ELF file - it has the wrong magic bytes at the start.
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/gcc-4.8.5/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 `/root/download/gcc-4.8.5/x86_64-unknown-Linux-gnu/libatomic'
make[3]: Leaving directory `/root/download/gcc-4.8.5/x86_64-unknown-linux-gnu/libatomic'
make[2]: Leaving directory `/root/download/gcc-4.8.5/x86_64-unknown-linux-gnu/libatomic'
make[1]: Leaving directory `/root/download/gcc-4.8.5'
3.建立软连接命令
[root@ximena ~]# sudo ln -s /usr/local/gcc-4.8.5/bin/gcc /usr/bin/gcc11
[root@ximena ~]# gcc11 -v
Using built-in specs.
COLLECT_GCC=gcc11
COLLECT_LTO_WRAPPER=/usr/local/gcc-4.8.5/libexec/gcc/x86_64-unknown-linux-gnu/4.8.5/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --prefix=/usr/local/gcc-4.8.5 --with-gmp=/usr/local/gmp-4.3.2 --with-mpfr=/usr/local/mpfr-3.1.4 --with-mpc=/usr/local/mpc-1.0.3
Thread model: posix
gcc version 4.8.5 (GCC)
[root@ximena ~]# sudo ln -s /usr/local/gcc-4.8.5/bin/g++ /usr/bin/g++11
[root@ximena ~]# g++11 -v
Using built-in specs.
COLLECT_GCC=g++11
COLLECT_LTO_WRAPPER=/usr/local/gcc-4.8.5/libexec/gcc/x86_64-unknown-linux-gnu/4.8.5/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --prefix=/usr/local/gcc-4.8.5 --with-gmp=/usr/local/gmp-4.3.2 --with-mpfr=/usr/local/mpfr-3.1.4 --with-mpc=/usr/local/mpc-1.0.3
Thread model: posix
gcc version 4.8.5 (GCC)