ubuntu中降低gcc版本

第一种方法:

安装的是13.04版本的ubuntu.

sudo apt-get install gcc-4.4 g++-4.4 g++-4.4-multilib
 sudo rm -rf /usr/bin/gcc /usr/bin/g++
 sudo ln -s /usr/bin/gcc-4.4 /usr/bin/gcc
 sudo ln -s /usr/bin/g++-4.4 /usr/bin/g++

 

gcc –v 如果输出如下显示的版本号(4.4.7),说明降低版本成功


在14.04版本ubuntu下,gcc版本为4.8,第一种办法无法实现.采用如下方法:

<span style="font-size: 13.3333px; font-family: Arial, Helvetica, sans-serif;">wfly@ubuntu:~/linux-3.2$  <span style="color: rgb(70, 70, 70); font-family: simsun; font-size: 14px; line-height: 21px; background-color: rgb(234, 247, 253);">sudo apt-get install gcc-4.4</span></span>
<span style="font-size: 13.3333px; font-family: Arial, Helvetica, sans-serif;">wfly@ubuntu:~/linux-3.2$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 40  </span><span style="color: rgb(70, 70, 70); font-family: simsun; font-size: 14px; line-height: 21px; background-color: rgb(234, 247, 253);">(这里“40” 是优先级,值越大优先级越高)</span>
<span style="font-size: 13.3333px; font-family: Arial, Helvetica, sans-serif;">wfly@ubuntu:~/linux-3.2$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 60</span><span style="font-size: 13.3333px; font-family: Arial, Helvetica, sans-serif;"> </span><span style="color: rgb(70, 70, 70); font-family: simsun; font-size: 14px; line-height: 21px; background-color: rgb(234, 247, 253);">(本机自带的设置为60更高的优先级)</span>

wfly@ubuntu:~/linux-3.2$ sudo update-alternatives --config gcc
There are 2 choices for the alternative gcc (providing /usr/bin/gcc).

  Selection    Path              Priority   Status
------------------------------------------------------------
* 0            /usr/bin/gcc-4.8   60        auto mode
  1            /usr/bin/gcc-4.4   40        manual mode
  2            /usr/bin/gcc-4.8   60        manual mode

Press enter to keep the current choice[*], or type selection number: 1       
<span style="color: rgb(70, 70, 70); font-family: simsun; font-size: 14px; line-height: 21px; background-color: rgb(234, 247, 253);">默认系统用最高优先级的, 这里我们选择1就可以了</span>

gcc -v看到如下结果表示降版本成功:

Using built-in specs.
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.4.7-8ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran --prefix=/usr --program-suffix=-4.4 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --disable-libmudflap --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.4.7 (Ubuntu/Linaro 4.4.7-8ubuntu1) 

对于g++版本改变也是使用这种方法。

如果想改为高版本的随时用update-alternatives --config 命令切换!




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值