Reputation: 1505
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.
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).
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?
Many thanks!!
Upvotes: 1
Views: 195
Reputation: 1505
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.
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 has the following line:
int main(void){
cout<<"this is file_02"<<endl;
return 1;
}
How do we work with two main() functions in the same project. How do we compile files separately and run them separately?
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) 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) 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) 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) 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.
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!!
Upvotes: 1
Reputation: 1457
You can use build configurations for your purpose. You can exclude/include source files from specific build configurations. Run configurations can then be used to run the exe built using a specific build configuration. You can manage build configurations from the project context menu. You can exclude or include files or folders from a build configuration by choosing the potion from the context menu of the file or folder
Upvotes: 2