Volker's comment is Good. -v will tell you what gcc is prepping the ld
command line with, so you can borrow chunks of it.
Sometimes when I'm trying to work out what's going on I use -v, and
then grab the full ld command line and cut and paste and execute that,
and fiddle 'till I've got it right.
Cut's out the middle man.
And I bet that link someone gave to this HJ Lu post...
======================================================================
Assuming you are using the GNU binutils, do
# gcc a.o -Wl,-Bstatic -lfoo -Wl,-Bdynamic -lbar
======================================================================
is good as well. HJ Lu is always worth a read.
On Sat, 29 Mar 2008, Volker Kuhlmann wrote:
Nuts! Didn't work! Got error:
/usr/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status
The first tool to use for finding out what happens with gcc linking is
gcc -v. This shows the complete linker command line as constructed by
gcc. Some libs are even included multiple times. It is often useful to
copy that ld line from the screen into the command line for testing
minor modifications. This output also shows that the gcc options
-static, -shared are position-independent and used for controlling the
entire linking process, and therefore no good for controlling the
linking of individual libraries.
You want to heavily make use of gcc -Wl,... but note that's
compiler/binutils dependent (as are, quite frankly the rest of the
compiler options although they tend to be more "standardised").
John Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : [EMAIL PROTECTED]
New Zealand