Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Linking to Libraries(Linker can't find libraries)
Linking to Libraries [message #847674] Tue, 17 April 2012 14:48 Go to next message
Andrew . is currently offline Andrew .
Messages: 2
Registered: April 2012
Junior Member
Hello all,

I'm a bit newer to using Eclipse under Linux (Kubuntu 11.10) and i'm having a problem linking to libraries. I downloaded SFML Library ( www.sfml-dev.org ) unzipped it into my project folder and then went to configure Eclipse CDT to see everything it needs. I went to the C++ precompiler and showed it where the includes were and that seems fine, but when I showed it where the libraries are and told it to use the sfml-system library it can't find it. I had to install (with the apt package management in Kubuntu) the SFML files to the systems library folders. Then the compiler's linker could see them and it worked fine. I'm confused as to why after adding the path to the library that the compiler is ignorant to where they are?
Re: Linking to Libraries [message #848492 is a reply to message #847674] Wed, 18 April 2012 09:20 Go to previous messageGo to next message
Axel Mueller is currently offline Axel Mueller
Messages: 1963
Registered: July 2009
Senior Member
How did you exactly specify the library search path? What is the resulting command line shown in the build console?
BTW, using external libraries is explained here
http://wiki.eclipse.org/CDT/User/FAQ#How_do_I_add_an_external_library_to_my_C.2B.2B_project.3F


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Linking to Libraries [message #848740 is a reply to message #848492] Wed, 18 April 2012 14:25 Go to previous messageGo to next message
Andrew . is currently offline Andrew .
Messages: 2
Registered: April 2012
Junior Member
I was able, with the help of the Linux distribution, track down the issue being the path I was telling Eclipse about had a full name of the libraries and not just the short name that the documentation (or the apt-get installation) used.

So my work around was to use my package manager to pull the libraries in, but now I went into the lib folder and created symlinks to the long names (libsfml-system.so.1.6 to sfml-system) like the linker was expecting and that resolved the issue.

I do wish to however point out that the documentation you linked me to suffers from being a bit out dated, or the version I have is inconsistent with its directions.

The path to the option is actually going to the project properties, then to C/C++ build, settings, under tool settings tab finding GCC C++ Linker and under that the libraries option. Then adding either files or folders. I'm not sure if there is a place to report that in or not.

Thank you very much for your help.
Re: Linking to Libraries [message #849966 is a reply to message #848492] Thu, 19 April 2012 16:19 Go to previous messageGo to next message
Chris Miami is currently offline Chris Miami
Messages: 3
Registered: July 2011
Junior Member
I am having a similar issue and this FAQ entry has 3 orthogonal suggestions for how to do it, leading the new user (me) to believe that no one really knows the real answer (none of the methods seemed to work).

There is another confusion, as there are two entirely different prefs panes (C/C++ Build/Settings and C/C++ General/Paths and Symbols) that seem to do the same thing, and no direction on why/when to use one or the other.

Chris
Re: Linking to Libraries [message #850650 is a reply to message #849966] Fri, 20 April 2012 07:50 Go to previous message
Axel Mueller is currently offline Axel Mueller
Messages: 1963
Registered: July 2009
Senior Member
Chris Miami wrote on Thu, 19 April 2012 18:19
I am having a similar issue and this FAQ entry has 3 orthogonal suggestions for how to do it, leading the new user (me) to believe that no one really knows the real answer (none of the methods seemed to work).

There is another confusion, as there are two entirely different prefs panes (C/C++ Build/Settings and C/C++ General/Paths and Symbols) that seem to do the same thing, and no direction on why/when to use one or the other.

Chris

C/C++ Build/Settings:
These are setting for the compiler.
- open Project Properties->C/C++ Build/Settings
- hit the "Libraries" item under "GCC C++ Linker"
- in the upper pane click the + symbol and enter name of your library; omit lib prefix and trailing .dll or .so; e.g. if your library is named libfoo.so you will enter foo
BTW, if your lib is called libfoo.so.1.0 you must create a symlink called libfoo.so that links to this file. The linker neeeds always libfoo.so (w/o version number) but for runtime libfoo.so.1.0 is needed!

- in the lower pane you can enter the path to the library (only necessary if your library is not in the system path, i.e. /usr/lib)



C/C++ General/Paths and Symbols:
Here you can define things for the Eclipse indexer if it was not able to automatically discover everything you need. The indexer is needed for code completion etc. This has *nothing* todo with the compiler settings!


If you are successful with the above steps you can adapt the instructions on the wiki page http://wiki.eclipse.org/CDT/User/FAQ#How_do_I_add_an_external_library_to_my_C.2B.2B_project.3F


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Previous Topic:Editing C Files Programatically
Next Topic:Make eclipse warn when editing Read-only files
Goto Forum:
  


Current Time: Wed Oct 22 08:10:23 GMT 2014

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

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