This is the mail archive of the
mailing list for the GCC project.
Re: Getting an error message from gcc libstdc++.a on Solaris 2.5.1 .
- To: Nissim dot Penias at ca dot com
- Subject: Re: Getting an error message from gcc libstdc++.a on Solaris 2.5.1 .
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Mon, 29 May 2000 10:31:18 +0200
- CC: gcc-help at gcc dot gnu dot org
- References: <770292EEED98D311A2D7009027DE04A201CDBF29@ukslms01.cai.com>
> I must mension the way that i built in order for you to know :
It seems that you followed the instructions carefully.
> The problem occurs after i am trying to compile using these two commands :
> g++ -c test_lib.cpp -fPIC
> g++ -o xxx.so test_lib.o -shared
> The error message that i get is :
> <unknown> 0x1668 /usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95.2/libstdc++.a(iovfscanf.o)
> ld: fatal :relocation remain against allocatable but non writable section collect2: ld returned 1 exit status .
> ld: fatal:relocation 1 exit status
I'm not exactly sure what the problem is; it may be that a patch from
Sun might correct this behaviour - you may want to contact Sun
The cause of this problem apparently is that libstdc++ was not
compiled with -fPIC; therefore, when building a shared library, the
linker complains. However, I thought that Solaris should handle this
One solution is to configure gcc with --enable-shared (add
--enable-threads while you recompile it); that will give you a
libstdc++.so, which is won't be included into test_lib.o. The downside
is that you'll have to arrange that libstdc++.so is located on your
system (e.g. via LD_LIBRARY_PATH).
Another alternative is to build a libstdc++.a which is compiled with
-fPIC. The GCC build process does not support this setup; you'd have
to arrange for that manually.