Ubuntu 12.04 LTS - 设置新版本的gcc

时间:2022-12-24 09:13:51

I have built gcc 4.8.2 based on the following community wiki answer: link When I check current gcc version in a terminal I get an info: 4.6.3 How to set the new gcc 4.8.2 as default ?

我已根据以下社区维基回答构建了gcc 4.8.2:链接当我在终端中检查当前的gcc版本时,我得到一个信息:4.6.3如何将新的gcc 4.8.2设置为默认值?

Solution: Remove --prefix=/app/gcc/4.8.0 from step 3 (community wiki answer). Besides libraries which are mentioned in step 2 I had to install also g++ and multilib.

解决方案:从步骤3中删除--prefix = / app / gcc / 4.8.0(社区维基回答)。除了在步骤2中提到的库之外,我还必须安装g ++和multilib。

2 个解决方案

#1


1  

Instead of building from source, and possibly losing all valuable patches the distro maintainers add, you should use the Ubuntu toolchain PPA which is maintained by the actual gcc maintainer.

发行版维护人员补充说,你应该使用由实际的gcc维护者维护的Ubuntu工具链PPA,而不是从源代码构建,并且可能丢失所有有价值的补丁。

Once you have the newer version, and possibly other intermediate versions, you can then chose between several binaries:

一旦你有了更新的版本,可能还有其他中间版本,你就可以在几个二进制文件之间进行选择:

$ ls -l /usr/bin/gcc-4* /usr/bin/gcc
lrwxrwxrwx 1 root root      7 Oct 11 21:47 /usr/bin/gcc -> gcc-4.8
-rwxr-xr-x 1 root root 255168 Jan 30  2013 /usr/bin/gcc-4.4
-rwxr-xr-x 1 root root 275952 Jul  2  2012 /usr/bin/gcc-4.5
-rwxr-xr-x 1 root root 357344 Jun 19  2013 /usr/bin/gcc-4.6
-rwxr-xr-x 1 root root 578840 Sep 23 15:24 /usr/bin/gcc-4.7
-rwxr-xr-x 1 root root 775888 Nov 15 09:35 /usr/bin/gcc-4.8
$ 

You can then pick the desired version by setting CC as a Makefile variable and various other means. You could also use dpkg-alternative to override the default (which in my Ubuntu 13.10 system just move from 4.5 to 4.8 with the most recent upgrade from 13.04).

然后,您可以通过将CC设置为Makefile变量和其他各种方法来选择所需的版本。您也可以使用dpkg-alternative覆盖默认值(在我的Ubuntu 13.10系统中,只需从4.5升到4.8,最近从13.04升级)。

#2


0  

Try to download source code from here ======> http://ftp.gnu.org/gnu/gcc/

尝试从这里下载源代码======> http://ftp.gnu.org/gnu/gcc/

tar xzf gcc-4.8.2.tar.gz
cd gcc-4.8.2


./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
$PWD/../gcc-4.8.2/configure --prefix=$HOME/gcc-4.8.2 
make
make install

#1


1  

Instead of building from source, and possibly losing all valuable patches the distro maintainers add, you should use the Ubuntu toolchain PPA which is maintained by the actual gcc maintainer.

发行版维护人员补充说,你应该使用由实际的gcc维护者维护的Ubuntu工具链PPA,而不是从源代码构建,并且可能丢失所有有价值的补丁。

Once you have the newer version, and possibly other intermediate versions, you can then chose between several binaries:

一旦你有了更新的版本,可能还有其他中间版本,你就可以在几个二进制文件之间进行选择:

$ ls -l /usr/bin/gcc-4* /usr/bin/gcc
lrwxrwxrwx 1 root root      7 Oct 11 21:47 /usr/bin/gcc -> gcc-4.8
-rwxr-xr-x 1 root root 255168 Jan 30  2013 /usr/bin/gcc-4.4
-rwxr-xr-x 1 root root 275952 Jul  2  2012 /usr/bin/gcc-4.5
-rwxr-xr-x 1 root root 357344 Jun 19  2013 /usr/bin/gcc-4.6
-rwxr-xr-x 1 root root 578840 Sep 23 15:24 /usr/bin/gcc-4.7
-rwxr-xr-x 1 root root 775888 Nov 15 09:35 /usr/bin/gcc-4.8
$ 

You can then pick the desired version by setting CC as a Makefile variable and various other means. You could also use dpkg-alternative to override the default (which in my Ubuntu 13.10 system just move from 4.5 to 4.8 with the most recent upgrade from 13.04).

然后,您可以通过将CC设置为Makefile变量和其他各种方法来选择所需的版本。您也可以使用dpkg-alternative覆盖默认值(在我的Ubuntu 13.10系统中,只需从4.5升到4.8,最近从13.04升级)。

#2


0  

Try to download source code from here ======> http://ftp.gnu.org/gnu/gcc/

尝试从这里下载源代码======> http://ftp.gnu.org/gnu/gcc/

tar xzf gcc-4.8.2.tar.gz
cd gcc-4.8.2


./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
$PWD/../gcc-4.8.2/configure --prefix=$HOME/gcc-4.8.2 
make
make install