Re: gcc linkage problems
From: Rolf Magnus (ramagnus_at_t-online.de)
Date: 10/06/03
- Next message: Marc Schellens: "Re: ostream mainpulators"
- Previous message: Attila Feher: "Re: ostream mainpulators"
- In reply to: Dave Joseph: "gcc linkage problems"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 06 Oct 2003 13:33:37 +0200
xpost and f'up2 gnu.g++.help, since that question is off-topic here.
Dave Joseph wrote:
> I'm trying to link with a static library and keep getting undefined
> references to symbols that are defined in the library. The library is
> called libmwunit.a and is located in /app/tp/mw/lib, I'm using the
> following link step:
>
> g++ -o target -static -L/app/tp/mw/lib -lmwunit TestConsumer.o
> TestApp.o
The order matters. With your command line, the linker first opens
libmwunit, but doesn't find any symbol there that it needs. So it
unloads that library and goes on. Then TestConsumer and TestApp are
linked, using some symbols that are not defined there. The linker
remembers them as unresolved and goes on, but since there is nothing
afterward, those symbols stay unresolved.
Try:
g++ -o target -static -L/app/tp/mw/lib TestConsumer.o TestApp.o -lmwunit
giving the linker a chance to use the lib to resolve the missing symbols
from your .o files.
> TestApp.o and TestConsumer.o are part of my test harness and target is
> the executable I am trying to produce. I have extracted objects from
> the archive to check that the symbols exist – they do – and I can link
> directly with them. I've also tried various other combinations of
> ordering for libraries objects with and without the static specifier.
Probably you didn't try the right one :)
- Next message: Marc Schellens: "Re: ostream mainpulators"
- Previous message: Attila Feher: "Re: ostream mainpulators"
- In reply to: Dave Joseph: "gcc linkage problems"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|