libftdi Archives

Subject: Re: Can not link with libftdi

From: Xiaofan Chen <xiaofanc@xxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Fri, 15 Feb 2013 10:48:57 +0800
On Fri, Feb 15, 2013 at 4:00 AM, Jim Paris <jim@xxxxxxxx> wrote:
> Ori Idan wrote:
>> I tried: gcc -o i2csend i2csend.c -lftdi
>>
>> Just changing -lftdi to be at the end of the command line and it workd.
>> I still wonder why?
>
> Your GCC probably passes --as-needed to the linker by default.  Ubuntu
> started doing this in Natty and Debian in Wheezy.  This means the
> linker only pulls in symbols from a library if it needs them.  When
> you put libftdi first, none of those symbols are needed yet and so
> nothing gets included.
>
> See e.g. 
> http://wiki.debian.org/ToolChain/DSOLinking#Onlylinkwithneededlibraries

Interesting to know that. I met similar problems and I was
also wondering what happened.

The Debian Wiki page is down now but Ubuntu wiki seems to
be even more detail.

+++++
https://wiki.ubuntu.com/NattyNarwhal/ToolchainTransition
"The --as-needed option also makes the linker sensitive to
the ordering of libraries on the command-line. You may need to
move some libraries later in the command-line, so they come
after other libraries or files that require symbols from them.
For example, the following link line is wrong, and needs to be
changed so that libraries come after objects that use them:

 gcc -Wall -lwheel -lcar -ltruck -o racetrack racetrack.c"
++++++++++++++++

How do I know if my system GCC passes --as-needed to
the linker by default?


-- 
Xiaofan

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread