Doc is misleading

David Daney ddaney@avtrex.com
Thu May 10 18:36:00 GMT 2007


Matthew Woehlke wrote:
> gccNewbie wrote:
>> Matthew Woehlke-3 wrote:
>>> Linux lets you get away with this wrong link order due to lazy symbol 
>>> resolution, whereas Windows does not. What you have done is asked to 
>>> first link to libmylib. Since no objects (actually, you don't *have* 
>>> any objects yet!) require any symbols from libmylib, no symbols are 
>>> imported. 
>>
>> That solved my problem very well! I should have tried that, but it's even
>> better to have this explanation of why it works.
> 
> Glad it was helpful! :-)
> 
>> It's odd that the manual was so deliberately misleading on this! While 
>> I was
>> trying to solve this myself, I read: "You can mix options and other
>> arguments. For the most part, the order you use doesn't matter. Order 
>> does
>> matter when you use several options of the same kind; for example, if you
>> specify -L more than once, the directories are searched in the order
>> specified."
> 
> Eeeeeeeh... *technically* it isn't wrong (you can mix -W, -f options, 
> for example) but I see why it confused you, and I agree that it *really* 
> ought to say something about -l being in the 'order can matter' 
> category. You are by no means the first person on Windows to get bitten 
> by this.
> 
> To whoever maintains the doc: we really should add something like "Note 
> that the order of objects, including libraries specified by -l, DOES 
> matter on some platforms.", perhaps with an even longer explanation as 
> well such as what was in my previous post.

Perhaps reading this would be helpful:

http://sourceware.org/binutils/docs-2.17/ld/Options.html

I think it explains how it works.

David Daney



More information about the Gcc-help mailing list