Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse C++ multiple projects common files

Tags:

c++

eclipse

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?

like image 555
Wes Miller Avatar asked Jul 31 '26 02:07

Wes Miller


1 Answers

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

like image 175
mohaps Avatar answered Aug 01 '26 19:08

mohaps



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!