gcc4.2.7升级到gcc 4.8出错

goolyun 发布于 2014/05/23 15:40
阅读 482
收藏 0
GCC

安装步骤是:

1.下载源码包

wget http:    //ftp.gnu.org/gnu/gcc/gcc-4.8.0/gcc-4.8.0.tar.bz2
解压:  tar -jxvf  gcc-4.8.0.tar.bz2
 
2.下载编译所需依赖库
cd gcc-4.8.0
./contrib/download_prerequisites
cd ..
 
3.建立编译输出目录
mkdir gcc-build-4.8.0
 
4.进入此目录,执行以下命令,生成makefile文件
cd  gcc-build-4.8.0
../gcc-4.8.0/configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
 
5.编译
make -j4
如果编译成功,则时间是比较长的,半个小时左右,所以如果你看它一直在输出没有立刻停下来,应该很开心!
 
6.安装
sudo make install
 
7.切换GCC到新版
确定新安装的GCC的路径,一般默认在/usr/local/bin下。可以先updatedb,然后locate gcc-4.8|tail找一下
ls /usr/local/bin | grep gcc
添加新GCC到可选项,倒数第三个是名字,倒数第二个参数为新GCC路径,最后一个参数40为优先级,设大一些之后就自动使用新版了 
update-alternatives --install /usr/bin/gcc gcc /usr/local/bin/i686-pc-linux-gnu-gcc 40 

8.确认当前版本已经切换为新版

gcc -v

我这里用ssh远程的,发现版本没变,断开重练下,重新生成会话后发现变成了4.8了!



出错:

在第4步,不能生成Makefile文件,错误信息是:

 checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /bin/sed
checking for gawk... gawk
checking for libatomic support... yes
checking for libitm support... yes
checking for libsanitizer support... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking whether g++ accepts -static-libstdc++ -static-libgcc... no
checking for gnatbind... no
checking for gnatmake... no
checking whether compiler driver understands Ada... no
checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f2
checking for objdir... .libs
checking for the correct version of gmp.h... no
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.


各位大神,这个怎么解决了?

加载中
返回顶部
顶部