Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » linking to shared libraries (-o) in Eclipse Oxygen C/C++ IDE(properly linking library names with -o extensions to present project)
linking to shared libraries (-o) in Eclipse Oxygen C/C++ IDE [message #1785499] Sun, 15 April 2018 19:19 Go to next message
Robert Gray is currently offline Robert GrayFriend
Messages: 12
Registered: May 2017
Junior Member
My project has both static (.a) and shared files(.so):

foo.a
foo.so
foo.so.1
foo.so.1.0
foo.so.1.0.0

I've tried compiling against the typical include files (.h) and static library files provided (foo.a), but I keep getting errors indicating I am missing other library files. If I try to link to the shared files (-l) the files become the same because of the truncation :

foo.a->foo
foo.so->foo
foo.so.1->foo
etc.
(project properties->settings->Tool Settings->Libraries)

Question: how do I link to the (.so) files in Eclipse? It appears the programming includes both static and shared libraries.
Re: linking to shared libraries (-o) in Eclipse Oxygen C/C++ IDE [message #1785506 is a reply to message #1785499] Mon, 16 April 2018 02:53 Go to previous messageGo to next message
David VavraFriend
Messages: 778
Registered: October 2012
Senior Member
According to the loader documentation, -lxxx (small L) looks for libxxx.so then libxxx.a
ftp://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_node/ld_3.html
Note that the format for a library name is libxxx.so or libxxx.a

To make this work with versioned names, a symlink is used
$ ls -l /usr/lib64 | grep FLAC
lrwxrwxrwx.  1 root root    16 Feb  3  2016 libFLAC.so -> libFLAC.so.8.3.0
lrwxrwxrwx.  1 root root    18 Feb  3  2016 libFLAC++.so -> libFLAC++.so.6.3.0
-rwxr-xr-x.  1 root root  104K Feb  3  2016 libFLAC++.so.6.3.0
-rwxr-xr-x.  1 root root  362K Feb  3  2016 libFLAC.so.8.3.0

If your library doesn't follow this naming convention
then you can include it where an object file would appear using no flags.
You'll likely also need to use the full path (relative can be used but it's tricky).

In Eclipse this would be in
Project --> Properties --> C/C++ Build --> Settings --> Tool Settings tab --> GCC C++ Linker --> Miscellaneous --> Other objects

[Updated on: Mon, 16 April 2018 03:35]

Report message to a moderator

Re: linking to shared libraries (-o) in Eclipse Oxygen C/C++ IDE [message #1785554 is a reply to message #1785506] Mon, 16 April 2018 15:11 Go to previous messageGo to next message
Robert Gray is currently offline Robert GrayFriend
Messages: 12
Registered: May 2017
Junior Member
I entered the library information under "other objects" as you suggested. I could be doing it wrong, but in any case it still didn't work.

By "work" (sorry) I mean I can't Eclipse to process the .so files in the project.

[Updated on: Mon, 16 April 2018 15:14]

Report message to a moderator

Re: linking to shared libraries (-o) in Eclipse Oxygen C/C++ IDE [message #1785571 is a reply to message #1785554] Mon, 16 April 2018 23:41 Go to previous message
David VavraFriend
Messages: 778
Registered: October 2012
Senior Member
Not sure what you expect Eclipse to be doing for you.
The extent of Eclipse's involvement is to take the information you provide and pass it to the loader.
Then execute the loader using make and display the resulting output.
Beyond getting the linker command line correct, I doubt your issue is with Eclipse.


"Didn't work" is a bit vague.
Perhaps you can post the build log that shows the problem.
You might have given Eclipse/CDT incorrect parameters for the linker.
If so, we might be able to help you.
But do be aware, your issue is most likely with the GNU loader.
Discussing the fine points of using external tools is beyond the scope of this forum.
Getting Eclipse to set up the command line is within scope though.

Understanding how to use the external tools outside of Eclipse will go a long way toward knowing what Eclipse expects.

[Updated on: Tue, 17 April 2018 00:48]

Report message to a moderator

Previous Topic:Oxygen Ubuntu 16.04 GTK 2 pauses
Next Topic:Function in included header file won't work
Goto Forum:
  


Current Time: Tue Sep 25 17:36:49 GMT 2018

Powered by FUDForum. Page generated in 0.01625 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top