This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
How to stop ld from searching dependend libs?
- From: Richter, Jörg <Joerg dot Richter at pdv-FS dot de>
- To: <binutils at sources dot redhat dot com>
- Date: Mon, 23 May 2005 10:56:07 +0200
- Subject: How to stop ld from searching dependend libs?
Imagine you have funcA defined in libA.so and funcB defined in libB.so
funcA calls funcB
I use following commands to build libA.so and libB.so
gcc -fPIC -o libB.so -shared funcb.c -Wl,--no-undefined -Wl,-rpath,.
gcc -fPIC -o libA.so -shared funca.c -Wl,--no-undefined -L. -lB -Wl,-rpath,.
Up to now nothing special I think.
Now there is an executable 'main' which calls funcA and funcB.
So you have this call graph
main -> funcA -> funcB
\________________^
If I link it like this:
(1) gcc -fPIC -o main main.c -Wl,--no-undefined -L. -lA # 1
Then there are no errors that funcB is undefined. Somehow ld uses the dependend lib of libA.so to resolve funcB.
BUT, if I build an shared lib called main:
gcc -fPIC -o main -shared main.c -Wl,--no-undefined -L. -lA # 2
ld doesn't examine the dependend libs and prints an error:
: undefined reference to `funcB'
How can I make ld behave the same like in (2) when building (1)?
To be exact: I want ld to print an error when the user hasn't supplied all libs he needs to build the executable. So I want the simple behavior and not the nifty dependend lib searching algorithm that ld uses in case (1). Is there an option to achieve this? I read 'man ld' up and down and found nothing.
Perhaps i'm just blind...
Joerg