This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Getting an error message from gcc libstdc++.a on Solaris 2.5.1 .


> 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
support.

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
case.

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.

Regards,
Martin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]