www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/25/23:16:59

From: Martin DOT Stromberg AT lu DOT erisoft DOT se (Martin Stromberg)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Troubles linking into a library
Date: 25 Aug 1999 12:41:07 GMT
Organization: Ericsson Erisoft AB, Sweden
Lines: 41
Message-ID: <7q0o93$ne5$1@antares.lu.erisoft.se>
References: <7q0a36$10c0$1 AT news DOT net DOT uni-c DOT dk>
NNTP-Posting-Host: spica-144.lu.erisoft.se
X-Newsreader: TIN [version 1.2 PL2]
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019