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

后端 未结 4 622
感情败类
感情败类 2021-01-02 16:10

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 referen
相关标签:
4条回答
  • 2021-01-02 16:36

    I'm not sure about paths for CDT build settings (not at my computer) but can't you use the workspace variable? Something like: ${workspace_loc}/boost_1_39_9

    Edit: OK, I did some searching and found some information on those variables, here. I think what you want is: ${project_loc:/boost_1_39_0} ?

    0 讨论(0)
  • 2021-01-02 16:45

    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.

    0 讨论(0)
  • 2021-01-02 17:00

    I solved this problem using the Preferences->General->Workspace->Linked Resources option.

    Basically you define a variable pointing to your workspace folder.

    Then add to your project the third-party folder using Add folder->Advanced->Link to folder in the filesystem, and use the Variables... button to use the previously created variable to point to the third-party folder (using the Extend button).

    Then you just need to add the folder to your include and library paths in the project settings.

    Easy as cake... :S

    0 讨论(0)
  • 2021-01-02 17:02

    Just a thought.. have you tried installing boost such that the includes go under /usr/include and /usr/lib/ or /lib. Then just add those paths in your build preferences. I have had similar issue, but then we resolved it by using custom makefiles. It worked for us because we already had the custom build framework and just need to do some changes to an existing makefile and copy it over to this project.

    0 讨论(0)
提交回复
热议问题