views:

355

answers:

1

Hi,

I have a set of Eclipse c projects that will all refer to a common shared base of code (a mix of .c and .h files in the same folder) but will be built that code differently on a per project basis.

The common code base may be edited from within each project but these edits will be fixes to be carried across all the projects. The common code will no diverge per project except for build options through defines.

If I create a project for this library it implies a library build with is not what I need. I need the resulting object files to land in the project that they are being built for. So a c/c++ project does not make sense.

The common code will be checked in to a subversion repo (as will each project). I could use "New folder -> Linked resource" but I would prefer to keep the projects independent of the directory structure the developer happens to be using.

Is there a clean way to do this?

Thanks.

+1  A: 

Hello,

I'm not sure this will work for your version of Eclipse, or for CDT (I tested it with Java), but it seems you should create a second source folder. Since a source folder are usually private to the project it exists in, you have to create a linked folder... (from your description above I think perhaps you've already done that, but for completeness of the answer I include the steps below).

I did it this way:

  1. Create a new item in your project
  2. Select folder (not a source folder but a simple folder)
  3. In the folder creation dialog click the "Advanced >>" button and check the "Link to folder in file system" check box
  4. Click "Browse" and select the folder of common source files
  5. Click finish

You now have a simple folder, but in order to include the files in the folder in your compilation (at least in Java it works this way) you need to create a source folder:

  1. Create a new item in your project
  2. Select "Source folder"
  3. Click "Browse" next to the "Folder name" text box
  4. Select your newly created linked folder

Now, in my version of Eclipse, and in Java, this folder is included in compilation of the code. It hopefully works the same way in CDT...

If you run an OS with real symbolic links (Linux, OSX?) you may also use a symlinked folder in your project for the extra source folder, and then you should be able to just do the "Source folder"-creation steps above.

If your version of Eclipse do not have a "Browse"-button in the Source Folder creation dialog, try just typing the same name in the text box.

Regards,

/E

Erik
P.s. and AFAIK the second set of steps can be performed for a folder regardless of where it comes from, but are required in order to include the folder in the compilation. D.s.
Erik