1

I have a C++ project in Eclipse Juno (Service Release 2) on Linux.

I need to reference a third party library, but its name includes the library's version:

libThirdParty.so.10.1

I tried following this post. But it seems I have an old version of ld, and it doesn't work. (I checked the man page)

I tried using the library's full name (path/name) but I don't know where to add it because it is not working.

I can not create a symbolic link of the library without the version.

In eclipse, Where should I reference the full library name? Is there another way to reference the library?

Community
  • 1
  • 1
Dzyann
  • 5,062
  • 11
  • 63
  • 95

2 Answers2

0

In the project explorer select your project and press Ctrl + Enter. This will popup the properties window.

enter image description here

Then, under C/C++ -> Settings in the Tool Settings Tab select Linker -> Libraries click on the button add and write the library name-version you want to link to.

Warning: Be aware that in a Linux system exist a thing named soname for shared libraries, read this answer for a detailed explanation about it.

Edit: To the comments

The thing is the linker will look for a file named lib<name>.so since your library's name is libThirdParty.so.10.1 and don't ends with .so don't match this pattern. This is not a problem you can solve with eclipse, this is a general linux behaviour. If your library name were libThirdParty.10.1.so (note the trailing .so) then you could use ThirdParty.10.1 as the library name in the libraries eclipse field.

Linux use this name convention in order to make easier handle various version of he same lib installed in the system. What you want to do can't be done without use a symbolic link or rename the library to libThirdParty.10.1.so.

Community
  • 1
  • 1
Raydel Miranda
  • 13,825
  • 3
  • 38
  • 60
  • I am not used to Linux, I normally work on Windows. From your warning I gather I need to install the shared library? I thought I could do like in windows that I get a dll from the source control and I can reference it. In the post I linked gcc supports receiving the full name of the file, the problem is that I don't know where to do that in Eclipse. When I add libThirdParty.so.10.1 in the field you pointed, it fails to build. – Dzyann Aug 04 '14 at 20:26
  • If the lib is not installed you also have to add the search directory for that library. Hence you have to add the directory where the lib are to the field `Library search path`, below the field I pointed. – Raydel Miranda Aug 04 '14 at 20:57
  • I added the path and it is finding another library in the same folder, but the other file doesn't have the version number. – Dzyann Aug 05 '14 at 12:09
  • According to the warning I pointed later, you can put a symbolic link to the library you want. The symbolic link must be named as `libThirdParty.so`, this would be the soname. This symlink goes in the same folder you have your library. The other file is "recognized" due to it's name match it's soname. – Raydel Miranda Aug 05 '14 at 12:14
  • In my question I indicated I couldn't use an alias. I meant by it symbolic link, I updated the question so it is more clear. Thanks for your help. – Dzyann Aug 05 '14 at 13:20
  • I have added some explanation ant the end of the answer. – Raydel Miranda Aug 05 '14 at 13:42
0

I coworker helped me to solve this:

  1. Right Click on the Project => Properties => C/C++ Build => Settings
  2. Under GCC C++ Linker => Miscellaneous: Write the full name of your library, including the library path. Similar to the indications on this post for building with GCC.
Community
  • 1
  • 1
Dzyann
  • 5,062
  • 11
  • 63
  • 95