|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的小伙伴们!本文转载自:http://wgkgood.blog.51cto.com/,对作者深表感激!
比来因为需求的缘故原由,必要把今朝gcc-4.4.4晋级到gcc-4.6.1,思索到有多台的缘故原由,做了一个剧本主动装置分离批量工具分发。
1、装置情况
体系版本:centos6.0X64
原GCC版本:gcc-4.4.4
新GCC版本:gcc-4.6.1
2、正式装置
1、下载装置的源码:
[plain]viewplaincopyprint?
- 以下必要下载以下包:
- gcc-4.6.1.tar.bz2gmp-4.3.2.tar.bz2mpc-0.8.1.tar.gzmpfr-2.4.2.tar.bz2
- 下载地点以下:
- wgetftp://gcc.gnu.org/pub/gcc/infrastructure/{gmp-4.3.2.tar.bz2,mpc-0.8.1.tar.gz,mpfr-2.4.2.tar.bz2}
- wgethttp://ftp.gnu.org/gnu/gcc/gcc-4.6.1/gcc-4.6.1.tar.bz2
- 便可!
[/code]
2、解压装置:装置有前后按次:GMP、MPFR、MPC、GCC
1.装置GMP:
[plain]viewplaincopyprint?
- tarjxfgmp-4.3.2.tar.bz2&&cdgmp-4.3.2/;./configure–prefix=/usr/local/gmp/&&make&&makeinstall
2.装置MPFR:
[plain]viewplaincopyprint?
- tarjxfmpfr-2.4.2.tar.bz2;cdmpfr-2.4.2/;./configure–prefix=/usr/local/mpfr–with-gmp=/usr/local/gmp&&make&&makeinstall
3.装置MPC:
[plain]viewplaincopyprint?
- tarxzfmpc-0.8.1.tar.gz;cdmpc-0.8.1;./configure–prefix=/usr/local/mpc–with-mpfr=/usr/local/mpfr–with-gmp=/usr/local/gmp&&make&&makeinstall
然后实行以下:
[plain]viewplaincopyprint?
- exportLD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc/lib:/usr/local/gmp/lib:/usr/local/mpfr/lib/</span>
//这一步很关头,设置变量,不设置前面会报错。
4.装置GCC:
[plain]viewplaincopyprint?
- tarjxfgcc-4.6.1.tar.bz2;cdgcc-4.6.1;./configure–prefix=/usr/local/gcc–enable-threads=posix–disable-checking–disable-multilib–enable-languages=c,c++–with-gmp=/usr/local/gmp–with-mpfr=/usr/local/mpfr/–with-mpc=/usr/local/mpc/&&make&&makeinstall
[plain]viewplaincopyprint?
- 装置终了便可!然后做一个链接就能够利用GCC了
- mkdir-p/data/backup/`date+%Y%m%d`
- mv/usr/bin/{gcc,g++}/data/backup/`date+%Y%m%d`
- 新建软链接:
- ln-s/usr/local/gcc/bin/gcc/usr/bin/gcc
- ln-s/usr/local/gcc/bin/g++/usr/bin/g++
3、测试GCC
间接输出gcc-v能够检察到gcc版本为4.6.1和相干的编译参数就ok了!附上一个最复杂的装置剧本:
[plain]viewplaincopyprint?
- #!/bin/sh
- ##automakeinstallgcc
- ##2012-07-03
- tarjxfgmp-4.3.2.tar.bz2&&cdgmp-4.3.2/;./configure–prefix=/usr/local/gmp/&&make&&makeinstall
- sleep1
- cd../;tarjxfmpfr-2.4.2.tar.bz2;cdmpfr-2.4.2/;./configure–prefix=/usr/local/mpfr–with-gmp=/usr/local/gmp&&make&&makeinstall
- cd../;tarxzfmpc-0.8.1.tar.gz;cdmpc-0.8.1;./configure–prefix=/usr/local/mpc–with-mpfr=/usr/local/mpfr–with-gmp=/usr/local/gmp&&make&&makeinstall
- cd../;tarjxfgcc-4.6.1.tar.bz2;cdgcc-4.6.1;./configure–prefix=/usr/local/gcc–enable-threads=posix–disable-checking–disable-multilib–enable-languages=c,c++–with-gmp=/usr/local/gmp–with-mpfr=/usr/local/mpfr/–with-mpc=/usr/local/mpc/
- if
- [$?-eq0];then
- echo“Thisgccconfigureissuccess”
- else
- echo“Thisgccconfigureisfailed”
- fi
- exportLD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc/lib:/usr/local/gmp/lib:/usr/local/mpfr/lib/
- make&&makeinstall
- [$?-eq0]&&echoThisismakeinstallsuccess
////--------------------------------------------------------------------------------------------------------------------------------------------------------------
configure:error:cannotcomputesuffixofobjectfiles:cannotcompile
Indeed,addingtheMPFRandGPMlibdirectoriestoLD_LIBRARY_PATHsolvestheproblem.ForsomereasonIthoughtconfigurewouldhandlethisformesinceIgaveit--with-gmpand--with-mpfrsettings.Wouldhavebeenniceifconfiguretestedforthisandgivenahelpfulerror.InanyeventIllclosethisoutasaninvalidbugreport.
必要装置gmp与mpfr而且必要在.bash_profile(一样平常在/root目次下)设置LD_LIBRARY_PATH,把GMP与MPFR对应的lib设置上如:LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpfr/2.4.0/lib:/usr/local/gmp/4.2.2/lib
exportLD_LIBRARY_PATH必定要重启失效大概利用source/root/.bash_profile
errorwhileloadingsharedlibraries:libXXX.so.X:cannotopensharedobjectfile:Nosuchfile
1、找到libXXX.so.X的路径,好比/usr/local/***/lib
2、cd/etc
3、geditld.so.conf
4、增加/usr/local/***/lib
5、ldconfig
欢迎大家来到仓酷云论坛! |
|