help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem in linking using g++.


From: Thomas Scheunemann
Subject: Re: Problem in linking using g++.
Date: 19 Aug 2005 11:51:13 GMT
User-agent: tin/1.4.4-20000803 ("Vet for the Insane") (UNIX) (Linux/2.4.20-30.9 (i686))

Amit Bhatia <amit.bhatia@gmail.com> wrote:
> Hi,
>  I am using gcc version 3.3 on os X 10.3.9
>  I am trying to create a library written in c++. First I get the object
> files *.o
> Then I use the following,

> ar ruv libmy.a file1.o file2.o file3.o file4.o

> Now I try to use it in a test file, using,

> g++ -pg  -O -Wno-deprecated  -ansi -pedantic -o test test.C
> -DANSI_HEADERS -D_G_HAVE_BOOL -I. -I/ALLTHEINCLUDEDIRS  -lmy -L.

> And I get the following error message:

> ld: archive: ./librat.a has no table of contents, add one with
> ranlib(1) (can't load from it)

> I have created library using the same method before on gcc 3.1, on RH
> 9.0 and never had problems. Is there something changed?
> How can I resolve this problem?

So why don't you do what the error message suggest?

"ranlib libmy.a" after the "ar ..."

This is in fact not a g++ problem, it is a linker problem. On some system the
linker requires a table of contents in the archive file. On some systems it
is automatically created by "ar". On others it is not and you have to do it
by hand. Looking into the man page of "ranlib" would probably have told you so.

Thomas Scheunemann


reply via email to

[Prev in Thread] Current Thread [Next in Thread]