设为首页 收藏本站
查看: 771|回复: 0

[shell] gcc 版本更新

[复制链接]

尚未签到

发表于 2015-12-15 14:24:15 | 显示全部楼层 |阅读模式
使用的 linux 内核支持的 gcc 版本是 4.7 ,并不能全面的支持  c++11 中的新特性,所以手动把 gcc 升级到 4.8 。
gcc 的编译与安装需要依赖三个文件 gmp , mpfr , mpc , 其中这三个文件之间也有一定的依赖关系 : mpfr 依赖 gmp , mpc 依赖 gmp 和 mpfr .
手动安装之后,把安装过程整理成脚本如下所示:





  • #!/bin/sh


  • #first create HOMES for new installing softwares store their binary executable files

  • GMP_HOME='/usr/local/gmp-6.0.0'
  • MPFR_HOME='/usr/local/mpfr-3.2.1'
  • MPC_HOME='/usr/local/mpc-1.0.3'
  • GCC_HOME='/usr/local/gcc-4.8.2'




  • #download each source file to the corresponding path
  • tempfile=`mktemp download.XXXXX`

  • echo 'here we create a file '

  • exec 3>$tempfile

  • echo 'https://ftp.gnu.org/gnu/gmp/gmp-6.0.0a.tar.xz'>&3

  • echo 'http://www.mpfr.org/mpfr-current/mpfr-3.1.2.tar.xz'>&3

  • echo 'ftp://ftp.gnu.org/gnu/mpc/mpc-1.0.3.tar.gz'>&3

  • echo 'http://gcc.skazkaforyou.com/releases/gcc-4.8.2/gcc-4.8.2.tar.gz'>&3

  • echo 'here we begin download corresponding files'

  • wget -i download.*


  • rm -f download.*


  • #decompression each source file package

  • tar -xzf gcc-4.8.2.tar.gz &&

  • tar -xzf mpc-1.0.3.tar.gz &&

  • xz -d mpfr-3.1.2.tar.xz &&

  • xz -d gmp-6.0.0a.tar.xz

  • tar -xvf mpfr-3.1.2.tar &&
  • tar -xvf gmp-6.0.0a.tar

  • rm -f *.tar.gz


  • #create directory for each binary executable files store
  • #/usr/local/ is preferred optional main directory branch

  • mkdir $GMP_HOME &&
  • mkdir $MPFR_HOME &&
  • mkdir $MPC_HOME &&
  • mkdir $GCC_HOME



  • #here MPFR depends on GMP library , and MPC depends on
  • #both GMP and MPFR , so we install GMP first

  •     #set gmp binary file installation path name and other compile info
  •     /Xshell/gmp-6.0.0/configure --prefix=$GMP_HOME

  •     #run make file and make install
  •     cd /Xshell/gmp-6.0.0 && make && make install
  • #-------------------------------------

  •     #set mpc binary file installation path name and other compile options
  •     /Xshell/mpfr/configure --prefix=$MPFR_HOME --with-gmp=$GMP_HOME

  •     #run make file and make install command
  •     cd /Xshell/mpfr-1.0.3 && make && make install
  • #-------------------------------------

  •     #set MPFR binary file installation path name and other dependency options
  •     /Xshell/mpc/configure --prefix=$MPC_HOME --with-gmp=$GMP_HOME --with-mpfr=$MPFR_HOME

  •     #run make file and make install command
  •     cd /Xshell/mpc-3.1.2 && make && make install
  • #-------------------------------------

  • echo 'dependency libraries are installed properly , now let set , compile and install gcc '

  • # here we begin to install gcc library

  • # first and most important is to add new installed three libraries'

  • # path to the /etc/profile , and update /etc/profile this file

  •    echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GMP_HOME:$MPFR_HOME:$MPC_HOME" | tee -a /etc/profile

  •    source /etc/profile

  • # change directory to gcc package downloaded path

  • #-------------------------------------
  •     #set binary executable file path

  •         /Xshell/gcc-4.8.2/configure --prefix=$GCC_HOME -enable-threads=posix \
  •     -disable-checking -disable-multilib -enable-languages=c,c++ \
  •         --with-gmp=$GMP_HOME --with-mpfr=$MPFR_HOME --with-mpc=$MPC_HOME


  •      echo "now we make and make install gcc , patience wait for almost 1 hour"

  •     #make and make install
  •      cd /Xshell/gcc-4.8.2 && make && make install

  •     #update the soft-link gcc and g++ in directory /usr/bin/
  •     mv /usr/bin/gcc /usr/bin/gcc47
  •     mv /usr/bin/g++ /usr/bin/gpp47

  •     ln -s $GCC_HOME/bin/gcc  /usr/bin/gcc
  •     ln -s $GCC_HOME/bin/g++  /usr/bin/g++


  • #-------------------------------------

  • #finally , check whether gcc is updated successfully
  • echo 'here we check version of the current gcc
  • g++ -v
运行之记得前要 chmod 755 一下

end

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-151614-1-1.html 上篇帖子: [shell] protobuf 安装流程 下篇帖子: expect shell问题综合
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表