美文网首页
gcc installation[GCC配置(命令最全)包新手“

gcc installation[GCC配置(命令最全)包新手“

作者: MYS_bio_man | 来源:发表于2020-10-23 11:13 被阅读0次

这么多年来跑程序,最恼火的是软件安装不上,又苦于root权限限制鄙人的发挥(相信你也一样)。而,导致各类软件安装不成功,多半由于gcc及各种相关lib和依赖的问题。基于此,某搜集资料,自行配置GCC,终于多次(重复是检验真理的标准)成功“搞定”,故,分享命令于此,愿你也能肆意操控gcc,任意“盘”各种gcc依赖相关之软件些!


(PS:切莫贪心/新,安装最新GCC版本是不明智的选择哟!!!自己掂量思考利弊。话不多说,这里以安装配置gcc-7.3.0为例,代码附上:)

## config and install gmp-6.1.0

# download into /lustre/gene/software

tar -xvf gmp-6.1.0.tar.bz2

cd gmp-6.1.0

mkdir /lustre/gene/local/gmp-6.1.0

./configure --prefix=/lustre/gene/local/gmp-6.1.0

make && make install

## config and install mpfr-3.1.4.tar.bz2

# download into /lustre/gene/software

tar -xvf  mpfr-3.1.4.tar.bz2

cd mpfr-3.1.4/

mkdir /lustre/gene/local/mpfr-3.1.4

./configure --prefix=/lustre/gene/local/mpfr-3.1.4 --with-gmp=/lustre/gene/local/gmp-6.1.0/

make && make install

#为了方便,添加PATH

export LD_LIBRARY_PATH=/lustre/gene/local/gmp-6.1.0/lib:$LD_LIBRARY_PATH

export C_INCLUDE_PATH=/lustre/gene/local/gmp-6.1.0/include:$C_INCLUDE_PATH

export LD_LIBRARY_PATH=/lustre/gene/local/mpfr-3.1.4/lib:$LD_LIBRARY_PATH

export C_INCLUDE_PATH=/lustre/gene/local/mpfr-3.1.4/include:$C_INCLUDE_PATH

## config and install mpc-1.0.3 (其安装依赖gmp和mpfr,这也是前面添加path的原因)

# download into /lustre/gene/software

tar -xvf mpc-1.0.3.tar.gz

cd mpc-1.0.3/

mkdir /lustre/gene/local/mpc-1.0.3/

./configure --prefix=/lustre/gene/local/mpc-1.0.3/ --with-gmp=/lustre/gene/local/gmp-6.1.0/ --with-mpfr=/lustre/gene/local/mpfr-3.1.4

make && make install

export LD_LIBRARY_PATH=/lustre/gene/local/mpc-1.0.3/lib:$LD_LIBRARY_PATH

export C_INCLUDE_PATH=/lustre/gene/local/mpc-1.0.3/include:$C_INCLUDE_PATH

'''

如果不希望看到如下configure的错误,一定要添加--with-gmp, --with-mpfr and/or --with-mpc参数及相关路径

configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.

Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify

their locations.  Source code for these libraries can be found at

their respective hosting sites as well as at

ftp://gcc.gnu.org/pub/gcc/infrastructure/.  See also

http://gcc.gnu.org/install/prerequisites.html for additional info.  If

you obtained GMP, MPFR and/or MPC from a vendor distribution package,

make sure that you have installed both the libraries and the header

files.  They may be located in separate packages.

'''

mkdir /lustre/gene/local/gcc-7.3.0

cd /lustre/gene/local/gcc-7.3.0

/lustre/gene/software/gcc-7.3.0/configure --prefix=/lustre/gene/local/gcc-7.3.0 --enable-threads=posix --disable-checking --disable-multilib --enable-languages=c,c++ --with-gmp=/lustre/gene/local/gmp-6.1.0 --with-mpfr=/lustre/gene/local/mpfr-3.1.4 --with-mpc=/lustre/gene/local/mpc-1.0.3

make && make install

(take few hours,去打几把荣耀吧!!)

# 添加最终环境变量到bash

export LD_LIBRARY_PATH=/lustre/gene/local/gmp-6.1.0/lib:$LD_LIBRARY_PATH

export C_INCLUDE_PATH=/lustre/gene/local/gmp-6.1.0/include:$C_INCLUDE_PATH

export LD_LIBRARY_PATH=/lustre/gene/local/mpfr-3.1.4/lib:$LD_LIBRARY_PATH

export C_INCLUDE_PATH=/lustre/gene/local/mpfr-3.1.4/include:$C_INCLUDE_PATH

export LD_LIBRARY_PATH=/lustre/gene/local/mpc-1.0.3/lib:$LD_LIBRARY_PATH

export C_INCLUDE_PATH=/lustre/gene/local/mpc-1.0.3/include:$C_INCLUDE_PATH

export PATH=/lustre/gene/local/gcc-7.3.0/bin:$PATH

export LD_LIBRARY_PATH=/lustre/gene/local/gcc-7.3.0/lib:/lustre/gene/local/gcc-7.3.0/lib64:$LD_LIBRARY_PATH

export C_INCLUDE_PATH=/lustre/gene/local/gcc-7.3.0/include:$C_INCLUDE_PATH

相关文章

网友评论

      本文标题:gcc installation[GCC配置(命令最全)包新手“

      本文链接:https://www.haomeiwen.com/subject/lbaddhtx.html