我如何编译和运行GCC 4.9.x? [英] How do I compile and run GCC 4.9.x?

查看:133
本文介绍了我如何编译和运行GCC 4.9.x?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行debian wheezy,并希望从GCC 4.7.2升级到GCC 4.9.0。

根据这些说明,我已安装 libgmp-dev libmpfr-dev libmpc-dev (我的软件包管理器分别给了我版本2:5.0.5 + dfsg-2,3.1.0-5和0.9-4)并运行以下代码来编译gcc(请注意,在我的情况下,它是4.9.0而不是4.6。 2):

  tar xzf gcc-4.6.2.tar.gz 
cd gcc-4.6.2
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
$ PWD /../ gcc-4.6.2 / configure --prefix = $ HOME / gcc-4.6.2
make
make install

现在我有一个 objdir 目录全是东西,但是g ++在哪里,我应该把这个目录放在哪里?



我猜我应该将它移动到 usr / local 并向我的 PATH 变量中添加内容,但我不知道究竟是什么,以及如何确保在我的旧gcc安装之前搜索它。


< (注意configure的 - 前缀选项)

  $ PWD /../ gcc-4.9.0 / configure --prefix = $ HOME / gcc-4.9.0 
make install

新的gcc将安装在 $ HOME / gcc-4.9.0 目录(应有子目录,如 bin lib share $ b

完整路径为 gcc 将会是 $ HOME / gcc-4.9.0 / bin / gcc g ++ (它符号链接到 gcc )将在这里: $ HOME / gcc-4.9.0 / bin / g ++



在objdir中不能单独使用 g ++ ,因为 gcc 编译器驱动程序实现了几种语言的驱动程序;模式(C或C ++)是基于 argv [0] (二进制名称,用于运行驱动程序: gcc g ++ ;这种模式也影响链接标志)和源文件扩展名( gcc )同时接受C和C ++程序作为编译入目标文件的输入)。因此, g ++ 可以通过 make install 生成为符号链接,并且存储生成的符号链接的地方是 $ prefix / bin



在建立GCC并安装到 $ HOME / gcc-4.9后.0 目录下,您可以使用它;但默认的系统gcc将不会更新。分布式gcc的更新应该通过分布式工具来完成( apt dpkg-build 等)。 Wheezy的系统级gcc的当前预构建版本是 4.7.2 4.8.2 为杰西和Sid和 4.9-2 为实验。


I'm running debian wheezy and wanted to upgrade from GCC 4.7.2 to GCC 4.9.0.

As per these instructions I installed libgmp-dev, libmpfr-dev and libmpc-dev (my package manager gave me versions 2:5.0.5+dfsg-2, 3.1.0-5 and 0.9-4 respectively) and ran the following to compile gcc (note that in my case it was 4.9.0 instead of 4.6.2):

tar xzf gcc-4.6.2.tar.gz
cd gcc-4.6.2
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
$PWD/../gcc-4.6.2/configure --prefix=$HOME/gcc-4.6.2 
make
make install

I now have a objdir directory full of stuff, but where is g++, and where should I put this directory?

I'm guessing I should move it to usr/local and add something to my PATH variable, but I don't know what exactly, and how to make sure it is searched before my old gcc install.

解决方案

After doing these commands (note the --prefix option of configure)

$PWD/../gcc-4.9.0/configure --prefix=$HOME/gcc-4.9.0 
make install

the new gcc will be installed in $HOME/gcc-4.9.0 directory (there should be subdirectories like bin, lib, share inside it).

Full path to gcc will be $HOME/gcc-4.9.0/bin/gcc, and g++ (which is symlink to gcc) will be here: $HOME/gcc-4.9.0/bin/g++.

There can be no separate g++ in objdir because gcc compiler driver implements drivers for several languages; the mode (C or C++) is selected based on argv[0] (name of binary, which was used to run driver: gcc or g++; this mode also affects linking flags) and on source file extensions (gcc accepts both C and C++ programs as input for compilation into object files). So, g++ may be generated as symlink by make install, and the place to store generated symlink is $prefix/bin.

After building the GCC and installing it in the $HOME/gcc-4.9.0 directory, you can use it; but default system gcc will be not updated. Update of distributive gcc should be done via distributive tools (apt, dpkg-build, etc). Current prebuild version of system-wide gcc for Wheezy is 4.7.2, 4.8.2 for Jessie and Sid and 4.9-2 for "Experimental".

这篇关于我如何编译和运行GCC 4.9.x?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆