Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using eclipse CDT without creating a project

Tags:

c++

eclipse

I am currently learning c++.My first language was python.I am used to coding in eclipse in pydev. I learn a language by writing a lot of code snippets and use the debugger extensively to understand what is actually happening. Now,I downloaded CDT for eclipse,since I am used to the interface.

But now,I am forced to create a project for every c++ file I write. I want a way to easily execute the files(very small,max 300 lines) in fast manner,and without creating new projects again and again.Any ideas? Currently I use eclipse like a text editor,and use g++ for compiling the files.

like image 844
elricL Avatar asked Jan 15 '11 14:01

elricL


1 Answers

I suggest you create one project containing all your files (assuming each one has its own main function), and inside this project, create one 'Build configuration' per program by using :

Project > Properties > C/C++ Build > Configuration > Manage... > New

To avoid multiple definition of main in each 'Build configuration', you will have to exclude each cpp file from the 'Build configurations' it doesn't belong to. For this, in the Navigator view :

Right click on the cpp file > Properties > C/C++ Build, and check 'Exclude from build' for each 'Build configuration' the source file does not belong to.

When everything compiles fine, you will be able to run or debug each program separately inside Eclipse by selecting the matching 'Build configuration'.
More info in this answer :
What files belong to a build target in CDT managed build?

I hope this will help!

like image 75
Francois Avatar answered Oct 20 '22 18:10

Francois