There was a question on the old project about how to organize large projects, I presume by using sub-folders I have the same questions:
When projects get complicated (like one I'm working on now with ~60 .h and .cpp files in my project), it would be a big help to be able to simplify the project by using sub-folders. I can do this, but so far only if each file's #include statements are very path aware using either relative paths:
#include "..\..\motor.h"
or absolute paths:
#include "C:\\workspace\MyProjA\motors\motor.h"
This makes it a real pain to move code, or modules into new projects because these paths need attention. Even within one project, I find spec'ing all these paths makes it too much trouble to organize with sub-folders.
3 QUESTIONS:
1) Is it possible to configure Eclipse to automatically look for any .h, .c, or .cpp files in any subfolder contained within a project? That way, the project would be organized, but as long as a file were somewhere in the project folder, their paths would not need to be explicitly declared everywhere.
2) I have one instance of Eclipse where the C/C++ Projects View lists a project's files with all the .h files followed by all the .cpp
files. Another instance of Eclipse shows files grouped by name, that is, the .h and .cpp files together. Where do you control this?
3) Finally, how do you make Eclipse show the Settings folder, and the configured Include folders for a given project (or not)?
I'm posting this message on the both the old and new forums to insure the broadest audience: sorry if you get two emails.
The original post was:
///////////////////////////////////////////////////////////////
My first 5213 application has grown to the point where I would like
to "modularize" ( if that's a word ) the code. I haven't been able to
find, or figure out, how to tell the compiler to compile and link
multiple source files.
I've found the ${INPUTS} macro in the C/C++ Build Tool Settings, but
not how to specify the file(s) to use.
Any help would be appreciated.
Is there a way to modularize a project with sub-folders?
-
- Posts: 513
- Joined: Sat Apr 26, 2008 7:14 am
Re: Is there a way to modularize a project with sub-folders?
Hello Ridge...
Did you ever find a solution for modularising your projects?
Regards,
Mike.
Did you ever find a solution for modularising your projects?
Regards,
Mike.
-
- Posts: 513
- Joined: Sat Apr 26, 2008 7:14 am
Re: Is there a way to modularize a project with sub-folders?
Yes, and for larger projects the resultant organization is probably worth the hassle. Here's how I do it in Rel22_RC2. I think this also should work in Rel22_RC3, but for odd reasons have not updated on the PC with me at the moment... (Don't ask!)
1) In the C/C++ or Navigator view, select your project. Right click. New/Folder. Add a subdirectory and name it appropriately. Add .h and .cpp file inside. The #includes in these files typically do not need the "..\" absolute path specifiers for subdirectories that are one directory down form you project, but after that you will probably need to add them to gain access to (non-system) files in other directories.
2) Once the files are inside the new subdirectory (or directories), select your project, right click to Properties. In the left window of the resultant dialog box, select "C/C++ Builders," and then in the "Tool Settings" tab, select "GNU C++ Compiler," and on right notice a box specifying the project's include paths. Add a new path to your subdirectory by clicking the small green "+" icon which opens another dialog where you spec the path. I do this by clicking the "Workspace" button and navigating to the directory. Click OK, Then OK a 2nd time. Repeat for each subdirectory.
It would be great if there were an automated way to configure these settings, perhaps a default project settings tab, or a text file specfying the paths?
1) In the C/C++ or Navigator view, select your project. Right click. New/Folder. Add a subdirectory and name it appropriately. Add .h and .cpp file inside. The #includes in these files typically do not need the "..\" absolute path specifiers for subdirectories that are one directory down form you project, but after that you will probably need to add them to gain access to (non-system) files in other directories.
2) Once the files are inside the new subdirectory (or directories), select your project, right click to Properties. In the left window of the resultant dialog box, select "C/C++ Builders," and then in the "Tool Settings" tab, select "GNU C++ Compiler," and on right notice a box specifying the project's include paths. Add a new path to your subdirectory by clicking the small green "+" icon which opens another dialog where you spec the path. I do this by clicking the "Workspace" button and navigating to the directory. Click OK, Then OK a 2nd time. Repeat for each subdirectory.
It would be great if there were an automated way to configure these settings, perhaps a default project settings tab, or a text file specfying the paths?