C++ Eclipse CDT 如何添加 gcc 4.6.3

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9840009/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 13:20:28  来源:igfitidea点击:

C++ Eclipse CDT How to add gcc 4.6.3

c++eclipsegccgnueclipse-cdt

提问by 2607

I am running Eclipse CDT in Redhat Enterprise, the default version of gcc compiler is 4.4.6. The support team added gcc 4.6.3 recently, I am wondering how can I set up Eclipse in such a way that I can choose to compile the application with either gcc 4.4.6 or 4.6.3.

我在 Redhat Enterprise 中运行 Eclipse CDT,gcc 编译器的默认版本是 4.4.6。支持团队最近添加了 gcc 4.6.3,我想知道如何设置 Eclipse,以便我可以选择使用 gcc 4.4.6 或 4.6.3 编译应用程序。

Thanks.

谢谢。

回答by Tomas Pruzina

If you really want both gcc 4.6 and 4.4 in your eclipse, you will have to adjust your build configurations (as far I know there is no "easy" way to do this by default).

如果你真的想要在你的 Eclipse 中同时使用 gcc 4.6 和 4.4,你将不得不调整你的构建配置(据我所知,默认情况下没有“简单”的方法来做到这一点)。

Project -> Properties -> C/C+++ Build -> Manage Configurations -> create new

项目 -> 属性 -> C/C++++ 构建 -> 管理配置 -> 新建

Once this is created (& selected) you set it just like other configurations in tree (Debug / Release).

一旦它被创建(& 选择),你就可以像树中的其他配置(调试/发布)一样设置它。

new_configuration > Discovery -> Compiler invocation command --> set path to gcc 4.6

new_configuration > Discovery -> Compiler invocation command --> 设置 gcc 4.6 的路径

I believe you have to do this per each project, Eclipse is sloppy in this area.

我相信每个项目都必须这样做,Eclipse 在这方面很草率。

回答by chanp

I've just follow this SO postand done that succesfully for Eclipse empty make project. Try adding or editing PATH variable under "Project property" => "C/C++ Build" => "Environment". This way you don't need to alter environment variable outside the Eclipse.

我刚刚按照这个SO post并成功地为 Eclipse 空 make 项目完成了这项工作。尝试在“项目属性”=>“C/C++ 构建”=>“环境”下添加或编辑 PATH 变量。这样您就不需要在 Eclipse 之外更改环境变量。

回答by dbrank0

I'm not sure you can have two versions configured in default CDT distribution. It will use the system default. What do you get if you do gcc -v? I guess 4.4.6. Put 4.6 in PATH before that, and it will use 4.6. And do restart eclipse, after you modify the path.

我不确定您是否可以在默认 CDT 发行版中配置两个版本。它将使用系统默认值。如果你执行 gcc -v,你会得到什么?我猜是 4.4.6。在此之前将 4.6 放入 PATH 中,它将使用 4.6。并在修改路径后重新启动eclipse。

Also see this on how to clear project "discovery profile".

另请参阅有关如何清除项目“发现配置文件”的内容