GCC最新版安装及错误解决
2014-05-11 23:23
417 查看
linux下gcc安装
等原因,则需要安装最新版gcc。
先查看已有的gcc版本
如果系统还没有任何gcc被安装,则需要从开发包中先安装默认的低版本的gcc
centos下也可以安装带gcc的开发工具:yum groupinstall "Development Tools"
若不先安装旧版本的话安装可能会出现如下错误:
[cpp] view
plaincopy
//=======================================
configure: error: no acceptable C compiler found in $PATH
//=======================================
2、下载
gcc下载地址
ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc
gcc在下面的 releases 文件夹内,目前最新版为 4.8.2
若直接安装会出现如下错误:
[cpp] view
plaincopy
//=============================出现错误=====================================
configure: error: Building GCC requires GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0+.
Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify
their locations.
//==========================================================================
因为缺少gcc依赖的gmp、mpfr、mpc三个软件,所以需要下载安装他们,他们在上面的
infrastructure 文件夹内可以找到。同时gmp与mpfr及mpc之间还有相互依赖关系,所以
要按下面顺序安装,并在 configure后面的选项后面带上所依赖软件的路径
下载好所有文件及解压后如下:
plaincopy
//1、解压gcc
$tar -jxvf gcc-4.8.2.tar.bz2
$cd gcc-4.8.2
//2、解压安装gmp
$tar -jxvf gmp-4.3.2.tar.bz2
$cd gmp-4.3.2
$./configure --prefix=/usr/local/gmp-4.3.2 //gmp安装路径
$make
$make check
$sudo make install
//3、解压安装mpfr
$tar -jxvf mpfr-2.4.2.tar.bz2
$cd mpfr-2.4.2
//congfigure后面是mpfr安装路径及依赖的gmp路径
$configure --prefix=/usr/local/mpfr-2.4.2 --with-gmp=/usr/local/gmp-4.3.2
$make
$make check
$sudo make install
//4、解压安装mpc
$tar -zxvf mpc-0.8.1.tar.gz
$cd mpc-0.8.1
//congfigure后面是mpc安装路径及依赖的gmp和mpfr路径
$configure --prefix=/usr/local/mpc-0.8.1
--with-gmp=/usr/local/gmp-4.3.2 --with-mpfr=/usr/local/mpfr-2.4.2
$make
$make check
$sudo make install
若没有下面的配置,则会出现如下的mpc库错误及其他库错误等等,所以需要进行一系列配置
//================================出现错误======================================
gcc error while loading shared libraries: libmpc.so.2:
cannot open shared object file:No such file or directory
//===============================================================================
//5、配置库路径
#vi /etc/profile //向/etc/profile文件末尾添加下面的语句(root权限下):
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/gmp-4.3.2/lib:
/usr/local/mpfr-2.4.2/lib:/usr/local/mpc-0.8.1/lib
#source /etc/profile //使其立即生效
#echo $LD_LIBRARY_PATH //查看配置是否成功
/usr/local/gmp-4.3.2/lib:/usr/local/mpfr-2.4.2/lib:/usr/local/mpc-0.8.1/lib //显示这个表示成功
#vi /etc/ld.so.conf //编辑这个文件,添加下面路径
/usr/local/mpc-0.8.1/lib
/usr/local/gmp-4.3.2/lib
/usr/local/mpfr-2.4.2/lib
$sudo ldconfig
//6、安装gcc
$./configure --prefix=/usr/local/gcc4.8.2 --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
$sudo make install
//7、配置gcc
#vi /etc/profile //向/etc/profile文件末尾添加下面的语句(root权限下):
export PATH=$PATH:/usr/local/gcc4.8.2
#source /etc/profile //使其立即生效
#rm /usr/bin/gcc //删除旧的软连接
#ln -s /usr/local/gcc4.8.2/bin/gcc /usr/bin/gcc //使新版本建立软连接
//下面的同理
#rm /usr/bin/g++
#ln -s /usr/local/gcc4.8.2/bin/g++ /usr/bin/g++
这样最终就安装更新成功了,安装过程时间不短,破费功夫,若依赖文件及配置等处理的好的话会快些,过程中会出现很多错误, 一定要耐心解决。
一般命令的话在一般用户下即可解决($),需要 root 权限的,可以用 su 切换到 root 下 (#),或者在一般用户下,命令前加 sudo ,
关于 sudo 可以查看:
http://blog.csdn.net/wtfmonking/article/details/15494295
最后再按上面的步骤安装新版。centos下可以:
[cpp] view
plaincopy
$sudo yum remove gcc-* -y
$sudo yum groupinstall "Development Tools"
1、准备工作
linux一般可以从软件包等方式直接安装gcc,但不一般不是最新版,比如需要支持C++11等原因,则需要安装最新版gcc。
先查看已有的gcc版本
如果系统还没有任何gcc被安装,则需要从开发包中先安装默认的低版本的gcc
centos下也可以安装带gcc的开发工具:yum groupinstall "Development Tools"
若不先安装旧版本的话安装可能会出现如下错误:
[cpp] view
plaincopy
//=======================================
configure: error: no acceptable C compiler found in $PATH
//=======================================
2、下载
gcc下载地址ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc
gcc在下面的 releases 文件夹内,目前最新版为 4.8.2
若直接安装会出现如下错误:
[cpp] view
plaincopy
//=============================出现错误=====================================
configure: error: Building GCC requires GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0+.
Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify
their locations.
//==========================================================================
因为缺少gcc依赖的gmp、mpfr、mpc三个软件,所以需要下载安装他们,他们在上面的
infrastructure 文件夹内可以找到。同时gmp与mpfr及mpc之间还有相互依赖关系,所以
要按下面顺序安装,并在 configure后面的选项后面带上所依赖软件的路径
下载好所有文件及解压后如下:
3、安装及错误解决
[cpp] viewplaincopy
//1、解压gcc
$tar -jxvf gcc-4.8.2.tar.bz2
$cd gcc-4.8.2
//2、解压安装gmp
$tar -jxvf gmp-4.3.2.tar.bz2
$cd gmp-4.3.2
$./configure --prefix=/usr/local/gmp-4.3.2 //gmp安装路径
$make
$make check
$sudo make install
//3、解压安装mpfr
$tar -jxvf mpfr-2.4.2.tar.bz2
$cd mpfr-2.4.2
//congfigure后面是mpfr安装路径及依赖的gmp路径
$configure --prefix=/usr/local/mpfr-2.4.2 --with-gmp=/usr/local/gmp-4.3.2
$make
$make check
$sudo make install
//4、解压安装mpc
$tar -zxvf mpc-0.8.1.tar.gz
$cd mpc-0.8.1
//congfigure后面是mpc安装路径及依赖的gmp和mpfr路径
$configure --prefix=/usr/local/mpc-0.8.1
--with-gmp=/usr/local/gmp-4.3.2 --with-mpfr=/usr/local/mpfr-2.4.2
$make
$make check
$sudo make install
若没有下面的配置,则会出现如下的mpc库错误及其他库错误等等,所以需要进行一系列配置
//================================出现错误======================================
gcc error while loading shared libraries: libmpc.so.2:
cannot open shared object file:No such file or directory
//===============================================================================
//5、配置库路径
#vi /etc/profile //向/etc/profile文件末尾添加下面的语句(root权限下):
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/gmp-4.3.2/lib:
/usr/local/mpfr-2.4.2/lib:/usr/local/mpc-0.8.1/lib
#source /etc/profile //使其立即生效
#echo $LD_LIBRARY_PATH //查看配置是否成功
/usr/local/gmp-4.3.2/lib:/usr/local/mpfr-2.4.2/lib:/usr/local/mpc-0.8.1/lib //显示这个表示成功
#vi /etc/ld.so.conf //编辑这个文件,添加下面路径
/usr/local/mpc-0.8.1/lib
/usr/local/gmp-4.3.2/lib
/usr/local/mpfr-2.4.2/lib
$sudo ldconfig
//6、安装gcc
$./configure --prefix=/usr/local/gcc4.8.2 --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
$sudo make install
//7、配置gcc
#vi /etc/profile //向/etc/profile文件末尾添加下面的语句(root权限下):
export PATH=$PATH:/usr/local/gcc4.8.2
#source /etc/profile //使其立即生效
#rm /usr/bin/gcc //删除旧的软连接
#ln -s /usr/local/gcc4.8.2/bin/gcc /usr/bin/gcc //使新版本建立软连接
//下面的同理
#rm /usr/bin/g++
#ln -s /usr/local/gcc4.8.2/bin/g++ /usr/bin/g++
4、最后
查看是否安装更新成功:这样最终就安装更新成功了,安装过程时间不短,破费功夫,若依赖文件及配置等处理的好的话会快些,过程中会出现很多错误, 一定要耐心解决。
一般命令的话在一般用户下即可解决($),需要 root 权限的,可以用 su 切换到 root 下 (#),或者在一般用户下,命令前加 sudo ,
关于 sudo 可以查看:
http://blog.csdn.net/wtfmonking/article/details/15494295
5、其他问题
如果不小心误删了 /usr/bin/gcc ,可以先删除旧版 gcc,在从软件包重新安装旧版,最后再按上面的步骤安装新版。centos下可以:
[cpp] view
plaincopy
$sudo yum remove gcc-* -y
$sudo yum groupinstall "Development Tools"
相关文章推荐
- GCC最新版安装及错误解决
- GCC最新版安装及错误解决
- Linux 安装gcc [原]解决Metadata file does not match checksum错误
- 关于win32移植android(最新的cocos2d-x安装错误和cygwin编译错误的解决)
- 关于Python安装模块出现error: command 'gcc' failed with exit status 1错误的解决方法
- Gentoo软件安装错误gcc-config: Active gcc profile is invalid解决办法
- 2016最新CocoaPods安装和错误解决
- 编译安装 gcc 4.8.2 --最新--解决QT错误
- 2016最新CocoaPods安装和错误解决 + 自己的经验
- 彻底解决“安装.Net Framework 3.5时出现错误”的问题
- Setup is missing prerequisites: MSXML6--安装SSMS错误提示 解决方法
- 安装apache遇到的几个错误及解决办法 [error] Apache2.2: Service is already installed.
- Ubuntu14.04 Graphlab安装及错误解决办法
- ubuntu安装openssh-server 报依赖错误的解决过程
- Linux安装软件时出现无法修正错误的解决方法
- 【技术贴】安装MYSQL最后一步出现错误,提示"终结点映射器中没有更多的终结点可用的解决"!
- 如何在Ubuntu系统中重新安装不同版本的Ubuntu!(……Not a COM32R image ……“错误的解决办法!
- Win8.1无法安装msi软件提示2502、2503错误怎么解决?
- 【共享】解决“无法显示进程。没有正确安装调试器。请运行安装程序安装或修复调试器。”错误的方法。
- CentOs安装Scrapy出现error: Setup script exited with error: command ‘gcc’ failed with exit status 1错误解决方案