Mail Archives: djgpp/1999/08/25/23:16:59
Troelz Denver (c938133 AT student DOT dtu DOT dk) wrote:
: Hi guys,
: I'm trying to link a set of files into a library. I am using the ar command
: as follows:
: ar -crus fileout.a file1 file2 file3
: This correctly gives the file fileout.a
: When I later link to this file:
: gcc file.c fileout.a
: in order to make an executable, I get the respond
: libout.a: could not read symbols: Archive has no index; run ranlib to
: add one
: The I use ranlib to add an index (-s on ar should have inserted the index):
: ranlib fileout.a
: When running gcc again I get the same answer as before. What am I doing
: wrong? Both ranlib and ar are version 2.8.1.
: BR's Troelz
I'm not an expert on archives but I think your problem might be that it is a
library but you pass it in such a way the compiler thinks it's an object
file.
Try "ar -crus libfileout.a file1 file2 file3; gcc file.c -lfileout.a".
Perhaps you need to add "-L." to the gcc command for it to find your library
(which I'm guessing is in the current directory).
Right,
MartinS
- Raw text -