Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Setting GCC linker library options (GCC linker options )
Setting GCC linker library options [message #1747509] Tue, 15 November 2016 14:55 Go to next message
Anne Creek is currently offline Anne CreekFriend
Messages: 275
Registered: September 2014
Senior Member
I am having heck of a time setting -L and -l options
Assuming this is correct GCC syntax to add -L
/usr/local/lib
why does GUI shows "/usr/local/lib" being added ?
Assuming -l should be added without extension why this
cv2 - no . no " fails to find the file?
but
:cv2.so links just fine ?

Second - what does -shared do ?
It makes no difference in linker output.
I used a "how to ' article which followed standard GCC syntax but added "package" .
I could not find any "packages" in my OS. Perhaps the ariticle was littel out of date?
It would be nice to have REAL sample code on how to implement links to library on current version of Eclipse ( 32 bits on 32 bit Ubuntu ).

PS When I get some answer I'll be happy to supply actual linker output.
Re: Setting GCC linker library options [message #1747561 is a reply to message #1747509] Wed, 16 November 2016 00:36 Go to previous message
David VavraFriend
Messages: 1417
Registered: October 2012
Senior Member
These from GNU may help with the linker parameters. You are pretty much expected by Eclipse to know how to use each tool in the tool chain as they aren't really part of Eclipse.

There are two versions of the linker documentation (GNU ld) available with subtle differences. Here they are:
https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html
https://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_node/ld_3.html

If you read them you will find that -shared is used to generate a ".so" library.
Also: -L is used to specify a library search path while
-l is used to refer to a specific library with a specific name format.
The first link tells you what that format is. (lib<name>.a, and though not stated, also lib<name>.so).


In Eclipse you can set the -L and -l options using the linker settings in the tool settings dialog.
Here's an article on how to do it for the C math library (libm.a)
http://stackoverflow.com/questions/8480013/eclipse-c-c-cdt-add-l-option-linking-math-module-gcc-lm

If the name doesn't fit the convention for the -l option then it can be added as an other object under Miscellaneous settings for the linker.

If you really want to learn more about using the linker then you should search for tutorials or ask at stackeoverflow and stackexchange. Once you know how to use the linker from the command line, doing so using Eclipse will be more obvious.

[Updated on: Wed, 16 November 2016 18:16]

Report message to a moderator

Previous Topic:CDT Arduino Baudrates
Next Topic:ImageMagick++ in Eclipse CDT
Goto Forum:
  


Current Time: Fri Jan 28 08:28:26 GMT 2022

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

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

Back to the top