linux 编译安装gcc5.3
很多讲安装gcc需要GMP、MPFR、MPC这三个库。先安装GMP,其次MPFR,最后才是MPC。
安装GCC 配置安装选项
#cd /usr/local/gcc-5.3.0
#/opt/gcc-5.3.0/configure --prefix=/usr/local/gcc-5.3.0 -enable-threads=posix -disable-checking -disable-multilib -enable-languages=c,c++ --with-gmp=/usr/local/gmp-4.3.2 --with-mpfr=/usr/local/mpfr-2.4.2 --with-mpc=/usr/local/mpc-0.8.1
#make
#make install
建立软链接
[root@rekfan.com/]#sudo ln -s /usr/local/gcc-5.3/bin/gcc gcc
[root@rekfan.com /]#sudo ln -s /usr/local/gcc-5.3/bin/g++ g++
添加环境变量
打开/etc目录下的bashrc文件添加如下代码:
LD_LIBRARY_PATH=:/usr/local/mpc-0.8.1/lib:/usr/local/gmp-4.3.2/lib:/usr/local/mpfr-2.4.2/lib:/usr/local/gcc-5.3/lib
export LD_LIBRARY_PATH
但实际这种在gcc configure 的时候指定GMP、MPFR、MPC路径的方法有的时候是不可行的。
参考下面gcc安装参考说明,将GMP、MPFR、MPC源码直接放在gcc目录下,再make && make install
GNU Multiple Precision Library (GMP) version 4.3.2 (or later)
Necessary to build GCC. If a GMP source distribution is found in asubdirectory of your GCC sources named gmp, it will be builttogether with GCC. Alternatively, if GMP is already installed but itis not in your library search path, you will have to configure with the--with-gmpconfigure option. See also--with-gmp-liband--with-gmp-include.The in-tree build is only supported with the GMP version thatdownload_prerequisites installs.
MPFR Library version 2.4.2 (or later)
Necessary to build GCC. It can be downloaded fromhttps://www.mpfr.org. If an MPFR source distribution is foundin a subdirectory of your GCC sources named mpfr, it will bebuilt together with GCC. Alternatively, if MPFR is already installedbut it is not in your default library search path, the--with-mpfrconfigure option should be used. See also--with-mpfr-liband--with-mpfr-include.The in-tree build is only supported with the MPFR version thatdownload_prerequisites installs.
MPC Library version 0.8.1 (or later)
Necessary to build GCC. It can be downloaded fromhttp://www.multiprecision.org/mpc/. If an MPC source distributionis found in a subdirectory of your GCC sources named mpc, itwill be built together with GCC. Alternatively, if MPC is alreadyinstalled but it is not in your default library search path, the--with-mpcconfigure option should be used. See also--with-mpc-liband--with-mpc-include.The in-tree build is only supported with the MPC version thatdownload_prerequisites installs.