avr-gcc-list
[Top][All Lists]
Advanced

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

Re: [avr-gcc-list] Building AVARICE on Cygwin


From: Joerg Wunsch
Subject: Re: [avr-gcc-list] Building AVARICE on Cygwin
Date: Mon, 21 Jul 2003 22:52:47 +0200 (MET DST)

As "Ralph Mason" <address@hidden> wrote:

>$ gcc -lbfd test.c
>/cygdrive/p/TEMP/ccmHuQtQ.o(.text+0x1f):test.c: undefined reference to
>`_bfd_init'
>collect2: ld returned 1 exit status
>
>I must be missing something simple.

Yes, so simple that it really took me another view and yet another
one to see it. ;-)

Order is important when linking libraries: each invocation of a -lfoo
option searches libfoo.a for all symbols that are currently
unresolved, plus for any additional unresolved references that result
out of linking of a module from that library.  So in your example,
since the unresolved reference to _bfd_init is caused later on (by the
temporary object file the compiler substitutes for test.c), it'll
never get resolved.

There are also cases where a library needs to be specified more than
once.  For example, by default, gcc adds

-lc -lgcc -lc

at the end.  First, libc.a is searched.  This might cause any
additional modules from libgcc.a to become required.  Finally, one of
these modules might again require further modules from libc.a...
-- 
J"org Wunsch                                           Unix support engineer
address@hidden        http://www.interface-systems.de/~j/


reply via email to

[Prev in Thread] Current Thread [Next in Thread]