www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/03/09/04:42:03

Date: Thu, 9 Mar 1995 08:54:19 +0100 (MET)
From: Finn Nielsen <fnie AT login DOT dknet DOT dk>
Sender: fnie AT login DOT dknet DOT dk
Reply-To: fnie AT login DOT dknet DOT dk
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Solved: Archiving .o-files into .a-library

Yesterday, I sent the following message to this list:

> When I try to convert .o files into .a files, using ar, I find
> that the compiler refuses to read the resulting library:
>
> Assuming the file coll.o, compiled from coll.cpp using "gcc coll.cpp -c":
>
> >ar -sr libcoll.a coll.o
> (no error, but then running the library through the compiler:)
>
> >gcc libcoll.a
> libcoll.a: could not read symbols: No symbols
>
>
> I've tried using nm to list the symbols in libcoll.a:
>
> >nm -s libcoll.a
> ...libcoll.o: File format not recognized
>
> However, the coll.o file links fine into the compiler, when specified
> directly. Can anyone help?

As it turns out, kindly pointed out to me by Art S. Kagel, the -s
option in ar _isn't_ equivalent to running ranlib; it is non-
functional. Running "ranlib libcoll.a" solved my problem.

So, when compiling .o-files into libraries, use:

>ar -r lib<library>.a *.o

>ranlib lib<library>.a

Thank you, everybody who contributed!

-Finn
______________________________________________________
 Finn Nielsen, AM MultiMedia
  email: fnie AT login DOT dknet DOT dk   fido: 2:238/117.15
   snail: Rihiimakivej 6, DK-9200 Aalborg SV, DENMARK
    phone: +45 98 18 96 77   fax: +45 98 18 63 09
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- Raw text -


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