C++ – Referencing 3rd party Libraries using *relative* paths in Eclipse-CDT

ceclipse-cdt

what is the best practice to reference 3rd party C++ components (e.g. includes, libraries) using relative paths in Eclipse-CDT?

  • I'm trying to reference Boost and Google protobuf.
  • I've put them each in a folder in my workspace, e.g. /home/user/workspace/boost_1_39_9
  • I've added a reference to that folder under build settings in the project properties, BUT eclipse won't let me specify that path as relative to the workspace folder, I have to choose it using filesystem and specify an absolute path

thanks,

  • Alex

Best Answer

Eclipse variables, such as ${workspace_loc} and ${project_loc} only work for things that are actually in the runtime Eclipse workspace. When you say you put them under the workspace in the filesystem, did you actually import the files into Eclipse (using new Project; or creating a linked folder in an existing project)?

If the files exist in the filesystem but not in Eclipse itself then Eclipse will only be able to access them with absolute paths.

BTW, CDT has variables of its own: ${WorkspaceDirPath} ${ProjDirPath} ${ProjName} which expand to the particular filesystem location.