In Eclipse/CDT, I wish to have several C++ projects (projA, projB, projC, etc.) that will all include some .c, .cpp and/or .h files from a common directory. Here is my existing file structure:
Workspace -> projA -> src
-> common ->src : a.c a.h b.cpp c.cpp d.c etc.
-> projB -> src
-< projC -> src
When I attempt to add a source file in ../common/src to projA, the Add a Source File tool complains that the file must be in the project.
So, how do I include, say ../common/src/a.c into ../projA -> src?
Eclipse has an option called add new source folder and an option in that dialogue to link to existing directory. You can link the “common” folder as a source folder in all of the projects pointing to the same directory.
Right click on project -> New -> Folder -> Advanced -> Link to alternate location
Once folder has been added,
Right click on Folder -> Buld Path -> Use as source folder