Sunday, August 26, 2012

Developing C++ shared libraries with Eclipse CDT

Con­sider the fol­low­ing not so uncom­mon sce­nario: you have a shared library project in Eclipse and an exe­cutable project which uses the shared library.

I found that you have to do some addi­tional things for build­ing, run­ning and debug­ging the exe­cutable project in Eclipse (note that I’m doing this on Linux using CDT 4.0.3):

Define your shared library’s project as a ref­er­ence for your appli­ca­tion. In order to do so open the project prop­er­ties of the exe­cutable project, go to project ref­er­ences and select the shared library project (where in my case “shared” is also the name of the shared library).

In the project set­tings of your exe­cutable project, add the shared library to the linker set­tings, as below:

  1. Select the project name and right click, then choose property,
  2. Select C/C++ Build > C/C++ Linker,
  3. Add the library name of your shared library,
  4. Specify the shared library path "${workspace_loc:/SharedLib/Debug}"

Reference:

http://dirkraffel.com/2008/06/27/developing-shared-libraries-with-eclipse-cdt/

No comments:

Post a Comment