Re: GTK+ library access issue?



On Mon, Oct 24, 2011 at 10:17 PM, David Buchan <pdbuchan yahoo com> wrote:
> ok. So, I did a complete reinstall of Ubuntu (it's relatively quick, so why
> not?).
> This did nothing. Smae old story.
>
> I then got back on the net and tried Paul's suggestion:
> "Try putting it [-lm] at the end of the command, just for kicks."
> i.e.,
>
> gcc test.c -lm
>
> Not only did that work for test.c, but it also solved my gtk problem!
> I'm gobsmacked.
> How come that works, but putting the lib flags before the filename(s)
> doesn't?

the gnu linker follows a unix tradition of interpreting the list of
explicitly and implictly provided object files names as a dependency
order. consider two files, a.o and b.o. suppose that a.o uses a
function or symbol found only in b.o. in general, the linker will be
able to link these two if the order given is "a.o b.o" but not if its
"b.o a.o".

there are exceptions to this even with the gnu linker, and certainly
with non-gnu linkers. but in general when you construct a link command
(such as "gcc -lm text.c") you need to think a bit about ordering
things so that when A has a dependency on B, A appears before B. this
applies whether its an explicit reference to an object file (like
"a.o") or something implicit like -lm or text.c

--p


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]