<1> GCC的源码安装

来源:互联网 发布:k歌软件电视 编辑:程序博客网 时间:2024/04/30 22:52

当我们安装好操作系统基本自带了gcc的编译器,由于版本和root 权限的问题,我们希望在自己的目录下创建一个相对独立的environment,这样我们更新起来也会比较方便.

要安装基本gcc 首先要gmp,mpfr和mpc.(ftp://ftp.gnu.org/gnu/gmp/; http://ftp.gnu.org/gnu/mpfr/; http://www.multiprecision.org/mpc)

gmp:  解压源码 然后./configure --prefix=PathA(你要安装的路径) --->make --->make install

mpfr:  这个要用到gmp, 解压源码 然后 ./configure --prefix=PathB --with-gmp=PathA --->make --->make install

mpc:  这个需要gmp和mpfr ,解压源码 然后 ./configure --prefix=PathC --with-gmp=PathA --with-mpfr=PathB --->make ---> make install

OK, 开始安装gcc,(https://gcc.gnu.org/)下载,解压源码 首先 把前面安装的3个软件的库加入系统的lib路径中(下面有介绍),configure --prefix=PathD --enable-threads=posix --disable-checking --disable-multilib --enable-languages=c,c++,fortran --with-gmp=PathA --with-mpfr=PathB --with-mpc=PathC --->make --->make install 

等待一段时间,基本的gcc就安装完成了,支持c,c++,fortran (在安装时的enable-languages指明)

对了,我们安装了这些软件后,还有加入系统路径中去,vi ~/.bash_profile ---> PATH=/home/xxxx/environment/gcc-4.9.1-feng/bin:$HOME/bin:$PATH

库文件要加入路径中 LD_LIBRARY_PATH=/home/xxxx/environment/gcc-4.9.1-feng/lib:/home/xxxx/environment/gcc-4.9.1-feng/lib64:/home/xxxx/environment/gmp-6.0.0-feng/lib:/home/xxxx/environment/mpc-1.0.2-feng/lib:/home/xxxx/environment/mpfr-3.1.2-feng/lib:$LD_LIBRARY_PATH. 其中 PATH=$PATH
LD_LIBRARY_PATH=$LD_LIBRARY_PATH表示系统默认的一些路径(如/usr/bin/) 不要去掉;  最后也别忘了后面的export PATH 和export LD_LIBRARY_PATH

ok 开始你的hello world 吧~

0 0
原创粉丝点击