Ubuntu 12.04 64bit 下安装编译GCC 4.1.2 绝对原创

1. 下载并解压源码:
wget http://mirrors.ustc.edu.cn/gnu/gcc/gcc-4.1.2/gcc-4.1.2.tar.bz2
tar jxvf gcc-4.1.2.tar.bz2

2. 安装依赖库及软件:
sudo apt-get install libc6-dev libgmp-dev libmpfr-dev texinfo (这一步可以省去)

3. 编译gcc:
cd gcc-4.1.2
mkdir build
cd build
../configure --prefix=/opt/gcc-4.1.2 --program-suffix=-4.1 --libexecdir=/opt/gcc-4.1.2/lib --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --disable-multilib --enable-languages=c,c++

make bootstrap
然后是漫长的等待。。。

4. 安装gcc:
make install
cd /opt/gcc-4.1.2/bin
ls -al
看到i686-pc-linux-gnu-gcc-4.1.2等文件就说明安装完成啦。

5. 切换gcc 4.1.2:
我一般喜欢在主目录下建立一个bin文件夹,而bin文件夹默认就在PATH中,然后在bin文件夹下链接gcc-4.1来切换gcc的不同版本。
cd ~
mkdir bin
ln -s /opt/gcc-4.1.2/bin/gcc-4.1 gcc
ln -s /opt/gcc-4.1.2/bin/g++-4.1 g++
ln -s /opt/gcc-4.1.2/bin/cpp-4.1 cpp
ln -s /opt/gcc-4.1.2/bin/gcov-4.1 gcov
ln -s gcc cc
ln -s g++ c++
现在重新登录,输入gcc -v 或 cc -v就可以显示gcc已经变成4.1.2版本啦。

注意编译时遇到的问题小结:

(1)makeinfo的问题

# ./configure 

接着就出现错误

WARNING: `makeinfo' is missing on your system. You should only need it if
you modified a `.texi' or `.texinfo' file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy `make' (AIX,
DU, IRIX). You might want to install the `Texinfo' package or
the `GNU make' package. Grab either from any GNU archive site.
make[3]: *** [fastjar.info] 错误 1
make[3]:正在离开目录 `/home/ssm/gcc-obj/fastjar'
make[2]: *** [all] 错误 2
make[2]:正在离开目录 `/home/ssm/gcc-obj/fastjar'
make[1]: *** [all-fastjar] 错误 2
make[1]:正在离开目录 `/home/ssm/gcc-obj'
make: *** [all] 错误 2
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值