making a library breaks the code???
Wen-King Su
wen-king at cit-vlsi.Caltech.Edu
Wed Mar 2 05:31:47 AEST 1988
In article <4079 at megaron.arizona.edu> lm at megaron.arizona.edu (Larry McVoy) writes:
<Hi. I'm running on a Vax 8600 (I think), 4.3BSD from Mt. Xinu. I have
>some C code in about 5 files. Normally I do things like this:
<
>$ cc application.c *.o ../lib/Tlib.a -o application
<
>Eventually "*.o" wil have to go into a library, so I tried this:
<
>$ ar cr stardoto.a `lorder *.o | tsort`
<$ ranlib stardoto.a
>$ cc application.c stardoto.a ../lib/Tlib.a -o application
<
>and the code breaks.
Your description is not very specific. My guess is that some .o files
in stardoto.a were not used by the loader when the loader is finished
with it. In the first 'cc', you force the loader to use all the .o
files; whereas, in the second 'cc', you let the loader pick only those
.o files that are needed at the time. If the second 'cc' terminates
with an error, then symbols in the .o files skipped by the loader are
referenced by the other libraries following it (Tlib.a, for example).
The loader will then complain because it could not find the symbol.
The loader does not go back to rescan its list of library files. If
the second 'cc' terminates without error, the .o files that were
skipped contain symbols having the name as those found in the libraries
that comes after stardoto.a. In that case, the wrong .o file will be
used. Most compiler has a flag that tells you what is being loaded
from which library.
/*------------------------------------------------------------------------*\
| Wen-King Su wen-king at vlsi.caltech.edu Caltech Corp of Cosmic Engineers |
\*------------------------------------------------------------------------*/
More information about the Comp.unix.wizards
mailing list