views:

1794

answers:

3

I'm new to Eclipse-CDT, setting up a new project for the first time. I'm trying to reference Boost without hardcoding an absolute path.

I've put boost in my workspace folder, e.g. /home/user/workspace/boost_1_39_0

I was then hoping to add an include directory pointing to that folder relative to the workspace, but Eclipse won't do that, it seems to only want to point to thinks in /home/user/workspace/[MyProjectNameHere]

Any tips? It doesn't seem to make sense to copy Boost into my project folder, because then it shows up in Eclipse and Eclipse wants to build it (sure, I could exclude it).

  • Alex
+2  A: 

IIRC, you should be able to right click the project and go into the C/C++ general settings. From there you can add specific include directories for the project to reference. Here's a couple of links that may help...

IBM Article

Eclipse Development

nathan
Thx, yes I can do that, but I guess my question is how do I do that using a relative path.
Alex Black
I updated the question to better reflect the relative path issue
Alex Black
+3  A: 

When adding an include file path in the CDT project (Project Properties/C/C++ General/Paths and Symbols), there are 3 buttons to browse for a location:

  • Variables...
  • Workspace...
  • File system...

If you press the Workspace... button, the path will be relative to the workspace/project. If you select the Variables... button, you'll get to incorporate variables such as ${WorkspaceDirPath}. The variables can also reference environment variables, which might be handy if you want a single install of boost to be referenced from projects that might reside anywhere on your machine.

If you incorporate variables into the path, make sure the "Is a workspace path" option is checked - otherwise the variable seems to get evaluated when you press "OK" instead of staying a variable to be evaluated at build time.

Michael Burr
thanks for pointing that option out, I don't want to put my settings there, those are IDE-wide, I want project-specific settings so other users can just get the project (and dependencies) from source control and then build.
Alex Black
In Visual Studio 2008 I'd just add a relative path to the project includes directories, e.g. "../boost_1_39_0"
Alex Black
Eclipse seems to 'resolve' the full paths if you simply type in a relative path - though checking the 'workspace relative' checkbox might fix that. Also - what do you mean about the settings being IDE-wide? For me they seem to be attached to the specific project. But note that I'm particularly knowlegable in Eclipse. I find a lot lacking in Eclipse/CDT (especially in documentation), but it's very much good enough that using it instead of a $5000 IDE for embedded development is a good choice a lot of the time.
Michael Burr
There are two spots I've found to enter these settings, the one you described seems to be not project specific. "C/C++ General" has the text beside it "Enable project specific settings" which is not checked (yet) for me.
Alex Black
The "Project specific settings" option seems to be a panel-to-panel option. For example, the one on the "C/C++ General" panel applies only to the Documentation tool setting. As far as I can tell, the "Paths and Symbols" settings are project-specific.
Michael Burr
ah, ok, thanks, I will try out those settings then.
Alex Black
Update: on re-reading my comments, I note that one says, "I'm particularly knowlegable in Eclipse" - I meant exactly the opposite - I'm **not** particularly knowlegable in Eclipse!
Michael Burr
I have a similar problem, and clicking "Workspace..." and selecting the folder my so file rests in will not work - the linker responds "no such file or directory". if I copy it to /usr/lib it works at once.
wsd
+1  A: 

I got this working doing roughly what Michael Burr suggested above:

Under Project Properties/C/C++ General/Paths and Symbols, I added paths like this:

${ProjDirPath}/../boost_1_39_0

  • Alex
Alex Black