From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joerg Faschingbauer To: help-gcc@gnu.org Subject: Re: Linking shared libraries on hpux 10.20 with gcc 2.92.1 fails !! Date: Tue, 30 Nov 1999 23:28:00 -0000 Message-ID: <86vh791ium.fsf@hwiw01.hyperwave.com> References: <38183EF6.39D5007F@oi42.kwu.siemens.de> <80cg0h$a0l$1@nnrp1.deja.com> X-SW-Source: 1999-11n/msg00173.html Message-ID: <19991130232800.GTmW_qAVTtXfx-33EhRNJ5WVu4iu_kf-k4y_3EoifMk@z> jd_wells@my-deja.com writes: > I am currently experiencing the exact same > problem. Did you ever find out what the problem > is? > > Any help would be appreciated... > JD Wells > > > In article > <38183EF6.39D5007F@oi42.kwu.siemens.de>, > "Dr. Armin Tschammer" > wrote: > > Hi, > > Now I succeded in compiling and installing the > gcc 2.95.1 on a hpux > > 10.20 box. > > I would like to create shared libraries and I > did the following: > > > > g++ -fpic -c a.C > > g++ -fpic -c b.C > > g++ -shared a.o b.o -o x.sl > > > > I got the following message: > > > > /usr/ccs/bin/ld: DP relative code in > file /var/tmp/cc2TTYoc.o - shared > > library must be position > > independent. Use +z or +Z to recompile. > > collect2: ld returned 1 exit status > > > > Any hints ?? A common trap in building shared C++ libs is that gcc itself (and libstdc++.a) does not bootstrap PICly by default. You have to tell it to. Configure as usual, and make bootstrap CFLAGS=-fPIC CXXFLAGS=-fPIC Also, pass -fPIC (-fpic?) on the link line as well because, when linking, g++ (collect2) generates code for the ctors of global objects to be called properly. This code has to be compiled PICly. I don't know if this cures all of your problems for the HP, but it sure helps along the way. I once managed to make a HP shared lib with gcc 2.7.2.3, and ended up with a weird link line that read as follows, for whatever reason. g++ -fPIC -shared -l ... \ -Xlinker +I -Xlinker _GLOBAL__DI \ -u __eprintf -u __pure_virtual -u __builtin_delete \ -u __builtin_new -u __builtin_vec_delete -u __builtin_vec_new \ -u __muldi3 -u __udivdi3 -u __umoddi3 -lgcc \ the_shared_lib.sl Joerg