Amit Bhatia <[EMAIL PROTECTED]> 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
_______________________________________________
Help-gplusplus mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to