如何使用Eclipse Luna在CDT中使用构建/运行配置 [英] How do I use Build/Run Configurations in CDT using Eclipse Luna

查看:230
本文介绍了如何使用Eclipse Luna在CDT中使用构建/运行配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮助我理解Eclipse中的运行配置吗?

这是我想解决的问题:
我正在使用CDT在Eclipse中开发一个c + +应用程序Luna 。我有两个源文件,让我们说我有file_01.cpp和file_02.cpp。它们都有main()函数。这两个文件都在同一个项目中。基本上我想编译然后运行配置#1和配置#2,gcc编译器只会分别编译file_01.cpp和file_02.cpp。我实现了混合成功,在相同的配置下,我将应用资源配置过滤器,但是这是低效的,因为我必须做/撤消相同的过滤操作多次。我相信这是配置用于。

Could someone please help me with an understanding of the Run Configurations in Eclipse?
Here is the issue I am trying to resolve: I am developing a c++ application using CDT in Eclipse Luna. I have to two source files, let's say I have file_01.cpp and file_02.cpp. Both of them have main() function. Both of these files are in the same project. Essentially I want to compile and then run a configuration #1 and configuration #2 where the gcc compiler would only compile file_01.cpp and file_02.cpp respectfully. I achieved mixed success where under the same configuration I would apply a Resource Configuration filter, but this is inefficient since I have to do/undo same filtering operation many times. I believe this is what the configurations are used for.

我看了eclipse手册,发现讨论这个主题的确切地方。不幸的是,这里没有太多的信息,我认为手动可能已过时(一些菜单项不是手动声称他们是)。

I looked at the eclipse manual, found exact place where this topic is discussed. Unfortunately, there is not much info there and also I think that manual might be outdated (some of the menu items are not where manual claims them to be).

所以我的理解是,我创建一个配置,包括我想要包括的任何文件,编译该配置,然后运行该配置。问题:我如何在Eclipse中这样做?

So my understanding is that I create a configuration, include whatever files I want to include, compile that configuration and then run that configuration. Question: How do I do that in Eclipse?

非常感谢!

推荐答案

我要感谢#Sasikanth为Eclipse上的指针。他的答案帮助我理解如何做到。我只是想更详细地讨论这个过程,明确地为他人的利益。

I want to thank #Sasikanth for the pointer on the Eclipse. His answer helped me to understand how to do it. I just want to go over the process more in detail and explicitly for the benefit of others.

情况:
假设您在同一个项目下有两个文件:file_01.cpp和file_02.cpp。

file_01.cpp具有以下行:

Situation: let's say you have two files under the same project: file_01.cpp and file_02.cpp.
file_01.cpp has the following line:

    int main(void){
    cout<<"this is file_01"<<endl;
return 1;
    }

file_02.cpp具有以下行:

file_02.cpp has the following line:

    int main(void){
    cout<<"this is file_02"<<endl;
return 1;
    }

我们如何在同一个项目中使用两个main我们如何单独编译文件并单独运行它们?

How do we work with two main() functions in the same project. How do we compile files separately and run them separately?

解决方案:(我使用的是eclipse-luna)
1)首先,你要去PROJECT- > BUILD CONFIGURATIONS-> MANAGE
将打开一个新窗口,您可以创建一些构建配置文件,让我们说PROFILE_1和PROFILE_2

SOLUTION: (I am using eclipse-luna) 1) First, you want to go PROJECT->BUILD CONFIGURATIONS->MANAGE A new window will open up and you can create some build profiles, lets say PROFILE_1 and PROFILE_2

2)在file_01.cpp上并选择RESOURCE CONFIGURATIONSS-> EXCLUDE FROM BUILD。在那里选择您想要关联file_01.cpp的任何构建配置文件。在我们的示例中:PROFILE_1。对file_02.cpp执行相同的过程

2) Next, right click on file_01.cpp and choose RESOURCE CONFIGURATIONS->EXCLUDE FROM BUILD. In there choose whichever build profile you want to associate file_01.cpp. In our case: PROFILE_1. Do the same procedure for file_02.cpp

3)现在您可以单独编译每个构建配置。首先你需要选择你想要编译的配置。转到PROJECT-> BUILD CONFIGURATIONS-> SET ACTIVE并选择要编译的构建配置。然后按CTRL-B。对其他配置也做同样的事情。

3) Now you are ready to compile each Build Configuration separately. First you need to choose the configuration you want to compile. go to PROJECT->BUILD CONFIGURATIONS->SET ACTIVE and choose the build config you want to compile. Then prese CTRL-B. Do the same thing for other configurations.

4)现在一切都已编译,但你需要告诉Eclipse它需要运行不同的配置。转到RUN-> RUN CONFIGURATIONS。将打开一个新窗口。在c / c ++应用程序下,添加一个新的配置文件。在右侧,您将有一个组合框选择Build Configurations,您可以在其中将RUN配置与BUILD配置相关联。这将告诉日食运行什么和什么时候。一旦你创建你的运行配置,按确定。

4) Now everything is compiled, but you need to tell Eclipse that it needs to run different configs. go to RUN->RUN CONFIGURATIONS. A new window will open up. Under c/c++ application, add a new profile. on the right hand side you will have an combo box choose "Build Configurations" where you can associate RUN config with BUILD config. This will tell the eclipse what to run and when. Once you create your run configs, press OK.

5)在最后一步,你想运行一个特定的配置。为此,你去工具栏,找到播放按钮。在它旁边,会有一个箭头。您单击它并选择要运行的配置。

5) in last step, you want to run a specific configuration. For that, you go to toolbar and look for the "play" button. Right next to it, there will be an arrow. You click on it and choose the configuration you want to run.

这是详细!再次感谢#Sasikanth的指针如何做。随意问问题是任何。谢谢!!

That is it in detail!! Again big thanks to #Sasikanth for the pointer on how to do it. Feel free to ask questions is any. Thanks!!

这篇关于如何使用Eclipse Luna在CDT中使用构建/运行配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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