ubuntu源码安装新版本gcc

起因是安装完wps for linux之后,启动wps演示 程序提示:/usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.14′ not found 即gcc版本不够。因此决定在我的ubuntu10.04上安装新版本的gcc。
网上的教程零零碎碎,而且颇多错误,我把自己的完整安装过程记录如下,仅供参考:
环境:ubuntu10.04lts x86 gnome2

首先下载gcc源码,以及gcc的依赖包源码。

gmp 4.3.2 ;mpfr 2.4.2 ;mpc 0.8.1 ; gcc4.6
下载地址:ftp://gcc.gnu.org/pub/gcc/infrastructure/
在/usr/local/下新建目录gcc46 及其子目录 gmp,mpfr,mpc,gcc

安装gmp

./configure —prefix=/usr/local/gcc46/gmp
sudo make
sudo make install

安装mpfr

./configure –prefix=/usr/local/gcc46/mpfr/ –with-gmp=/usr/local/gcc46/gmp/
sudo make
sudo make install

安装mpc

sudo apt-get install libgmp3-dev
sudo apt-get install libmpfr-dev
./configure –prefix=/usr/local/gcc46/mpc/
sudo make
sudo make install
sudo gedit /etc/profile
添加:export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/gcc46/mpfr/lib:/usr/local/gcc46/mpfr/include:/usr/local/gcc46/gmp/lib:/usr/local/gcc46/gmp/include:/usr/local/gcc46/mpc/lib:/usr/local/gcc46/mpc/include
注销重启电脑
PS:请严格按照安装顺序安装。

安装gcc

./configure –prefix=/usr/local/gcc46/gcc/ –with-gmp=/usr/local/gcc46/gmp/ –with-mpfr=/usr/local/gcc46/mpfr/ –with-mpc=/usr/local/gcc46/mpc/
sudo make
sudo make install

最后解决 libstdc++版本不够问题,参考以下英文:

I’m compiling gcc 4.6 from source, and apparently
sudo make install
didn’t catch this one. I dug around and found
gcc/trunk/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.15
I copied it in to /usr/lib and redirected libstdc++.so.6 to point to the new one, and now everything works.

发表评论

电子邮件地址不会被公开。 必填项已用*标注

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>