Fun with shared libs on HPUX - Request for help

Robert A Nesius rnesius@ichips.intel.com
Mon Mar 27 10:09:00 GMT 2000


On 27 Mar 2000, Alexandre Oliva wrote:

> On Mar 26, 2000, Robert A Nesius <rnesius@ichips.intel.com> wrote:
> 
> > But the problem I'm running into is that my libstdc++ lib is
> > apparantly not really a shared library, even though -fPIC is getting
> > set by the configure.
> 
> > /usr/ccs/bin/ld: DP relative code in file /usr/intel/pkgs/gcc/2.95.1/lib/gcc-lib/hppa1.1-hp-hpux10.20/2.95.1/libstdc++.a(iostream.o) - shared library must be position
>                                                                                                                          ^
> See, it's linking with the static version of libstdc++, for some
> reason.   e reason I don't understand.  Check whether libstdc++.sl
> was installed, and, if it was, where it lives.

Gotcha.  From my gmake.out file (which captured all the stdio and
stderr from the build, I see libstdc++.a being created, and then 
presumably libstdc++.sl...  

mv tlist stdlist
rm -f tlibstdc++.a.2.10.0
ar rc tlibstdc++.a.2.10.0 `cat stdlist`
mv tlibstdc++.a.2.10.0 libstdc++.a.2.10.0
true libstdc++.a.2.10.0
rm -f libstdc++.a
ln -s libstdc++.a.2.10.0 libstdc++.a || cp libstdc++.a.2.10.0 libstdc++.a
rm -f tlist
cp stdlist tlist
if [ x"yes" = xyes ]; then \
  sed 's,\([A-Za-z_]*\.o\),pic/\1,g' tlist > tlist2 ; \
  mv tlist2 tlist ; \
else true ; fi
mv tlist piclist
/fs3/comp.apps_build.1/gcc-2.95.1/hpux_10.20/gcc/xgcc -B/fs3/comp.apps_build.1/g
cc-2.95.1/hpux_10.20/gcc/ -B/usr/intel/pkgs/gcc/2.95.1/hppa1.1-hp-hpux10.20/bin/
 -g -O2 -fno-implicit-templates -fPIC -shared -o libstdc++.sl `cat piclist` 

But after that only two more references to libstdc++.sl exist in 
the 4 megabyte log: 

        if (cd ../${dir}/${lib}; gmake "SHELL=/bin/sh" "INSTALL=/bin/sh /fs3/com
p.apps_build.1/gcc-2.95.1/gcc-2.95.1/install-sh -c" "INSTALL_DATA=/bin/sh /fs3/c
omp.apps_build.1/gcc-2.95.1/gcc-2.95.1/install-sh -c -m 644" "INSTALL_PROGRAM=/b
in/sh /fs3/comp.apps_build.1/gcc-2.95.1/gcc-2.95.1/install-sh -c " "prefix=/usr/
intel/pkgs/gcc/2.95.1" "exec_prefix=/usr/intel/pkgs/gcc/2.95.1" "tooldir=/usr/in
tel/pkgs/gcc/2.95.1/hppa1.1-hp-hpux10.20" "gxx_include_dir=/usr/intel/pkgs/gcc/2
.95.1/include/g++-3" "libsubdir=/usr/intel/pkgs/gcc/2.95.1/lib/gcc-lib/hppa1.1-h
p-hpux10.20/2.95.1" "gcc_version=2.95.1" "gcc_version_trigger=/fs3/comp.apps_bui
ld.1/gcc-2.95.1/gcc-2.95.1/gcc/version.c" "AR=ar" "AR_FLAGS=rc" "CC=/fs3/comp.ap
ps_build.1/gcc-2.95.1/hpux_10.20/gcc/xgcc -B/fs3/comp.apps_build.1/gcc-2.95.1/hp
ux_10.20/gcc/ -B/usr/intel/pkgs/gcc/2.95.1/hppa1.1-hp-hpux10.20/bin/" "CXX=/fs3/
comp.apps_build.1/gcc-2.95.1/hpux_10.20/gcc/xgcc -B/fs3/comp.apps_build.1/gcc-2.
95.1/hpux_10.20/gcc/ -B/usr/intel/pkgs/gcc/2.95.1/hppa1.1-hp-hpux10.20/bin/" "CF
LAGS=-g -O2" "CXXFLAGS=-g -O2" "NM=nm" "RANLIB=true" "LIBCFLAGS=-g -O2" "LIBCXXF
LAGS=-g -O2 -fno-implicit-templates" "LOADLIBES=" "LDFLAGS=" "MAKEINFO=/fs3/comp
.apps_build.1/gcc-2.95.1/hpux_10.20/texinfo/makeinfo/makeinfo  " "SHLIB=libstdc+
+.sl" "SHCURSES=" "RUNTESTFLAGS=" \
                        CFLAGS="-g -O2 ${flags}" \
                        CXXFLAGS="-g -O2 ${flags}" \
                        LIBCFLAGS="-g -O2 ${flags}" \
                        LIBCXXFLAGS="-g -O2 -fno-implicit-templates ${flags}" \
                        LDFLAGS=" ${flags}" \
                        all); then \
          true; \
        else \
          exit 1; \
        fi; \
      else true; \
      fi; \
    fi; \
  done; \
fi
if [ x"yes" = xyes ] && [ ! -d pic ]; then \
  mkdir pic; \
else true; fi
touch stamp-picdir
cd ../libio ; gmake "SHELL=/bin/sh" "INSTALL=/bin/sh /fs3/comp.apps_build.1/gcc-
2.95.1/gcc-2.95.1/install-sh -c" "INSTALL_DATA=/bin/sh /fs3/comp.apps_build.1/gc
c-2.95.1/gcc-2.95.1/install-sh -c -m 644" "INSTALL_PROGRAM=/bin/sh /fs3/comp.app
s_build.1/gcc-2.95.1/gcc-2.95.1/install-sh -c " "prefix=/usr/intel/pkgs/gcc/2.95
.1" "exec_prefix=/usr/intel/pkgs/gcc/2.95.1" "tooldir=/usr/intel/pkgs/gcc/2.95.1
/hppa1.1-hp-hpux10.20" "gxx_include_dir=/usr/intel/pkgs/gcc/2.95.1/include/g++-3
" "libsubdir=/usr/intel/pkgs/gcc/2.95.1/lib/gcc-lib/hppa1.1-hp-hpux10.20/2.95.1"
 "gcc_version=2.95.1" "gcc_version_trigger=/fs3/comp.apps_build.1/gcc-2.95.1/gcc
-2.95.1/gcc/version.c" "AR=ar" "AR_FLAGS=rc" "CC=/fs3/comp.apps_build.1/gcc-2.95
.1/hpux_10.20/gcc/xgcc -B/fs3/comp.apps_build.1/gcc-2.95.1/hpux_10.20/gcc/ -B/us
r/intel/pkgs/gcc/2.95.1/hppa1.1-hp-hpux10.20/bin/" "CXX=/fs3/comp.apps_build.1/g
cc-2.95.1/hpux_10.20/gcc/xgcc -B/fs3/comp.apps_build.1/gcc-2.95.1/hpux_10.20/gcc
/ -B/usr/intel/pkgs/gcc/2.95.1/hppa1.1-hp-hpux10.20/bin/" "CFLAGS=-g -O2  -threa
ds" "CXXFLAGS=-g -O2  -threads" "NM=nm" "RANLIB=true" "LIBCFLAGS=-g -O2  -thread
s" "LIBCXXFLAGS=-g -O2 -fno-implicit-templates  -threads" "LOADLIBES=" "LDFLAGS=
-threads" "MAKEINFO=/fs3/comp.apps_build.1/gcc-2.95.1/hpux_10.20/texinfo/makeinf
o/makeinfo  " "SHLIB=libstdc++.sl" "SHCURSES=" "RUNTESTFLAGS=" iostream.list
gmake[5]: `iostream.list' is up to date.

>From the make install: 
if [ x"yes" = xyes ]; then \
  sed 's,\([A-Za-z_]*\.o\),pic/\1,g' tlist > tlist2 ; \
  mv tlist2 tlist ; \
else true ; fi
mv tlist piclist
/fs3/comp.apps_build.1/gcc-2.95.1/hpux_10.20/gcc/xgcc -B/fs3/comp.apps_build.1/g
cc-2.95.1/hpux_10.20/gcc/ -B/usr/intel/pkgs/gcc/2.95.1/hppa1.1-hp-hpux10.20/bin/
 -g -O2 -fno-implicit-templates -fPIC -shared -o libstdc++.sl `cat piclist` 

Checking the build area and the install area for the shared lib itself: 

# The build area:
[dtthp204]-> hpux_10.20 27> find . -name '*libstdc++*' -print
./hppa1.1-hp-hpux10.20/threads/libstdc++
./hppa1.1-hp-hpux10.20/threads/libstdc++/libstdc++.a
./hppa1.1-hp-hpux10.20/threads/libstdc++/libstdc++.sl
./hppa1.1-hp-hpux10.20/threads/libstdc++/libstdc++.a.2.10.0
./hppa1.1-hp-hpux10.20/libstdc++
./hppa1.1-hp-hpux10.20/libstdc++/libstdc++.a
./hppa1.1-hp-hpux10.20/libstdc++/libstdc++.sl
./hppa1.1-hp-hpux10.20/libstdc++/libstdc++.a.2.10.0
[dtthp204]-> hpux_10.20 28> cd /usr/intel/pkgs/gcc/2.95.1/

# The install area
[dtthp204]-> 2.95.1 29> find . -name '*libstdc++*' -print
./lib/gcc-lib/hppa1.1-hp-hpux10.20/2.95.1/threads/libstdc++.a
./lib/gcc-lib/hppa1.1-hp-hpux10.20/2.95.1/libstdc++.a
./lib/threads/libstdc++.a.2.10.0
./lib/threads/libstdc++.sl
./lib/libstdc++.a.2.10.0
./lib/libstdc++.sl
[dtthp204]-> 2.95.1 30> cd lib

[dtthp204]-> lib 34> file libstdc++.sl
libstdc++.sl:   PA-RISC1.1 shared library -not stripped

[dtthp204]-> lib 37> file libstdc++.a.2.10.0 
libstdc++.a.2.10.0:     archive file -PA-RISC1.1 relocatable library

[dtthp204]-> ~ 38> /usr/intel/pkgs/gcc/2.95.1/bin/g++ -c -shared -fpic my_helloworld.cpp
[dtthp204]-> ~ 39> /usr/intel/pkgs/gcc/2.95.1/bin/g++ -shared -fpic -o libworld.sl my_helloworld.o
/usr/ccs/bin/ld: DP relative code in file /usr/intel/pkgs/gcc/2.95.1/lib/gcc-lib/hppa1.1-hp-hpux10.20/2.95.1/libstdc++.a(iostream.o) - shared library must be position
    independent.  Use +z or +Z to recompile.
collect2: ld returned 1 exit status

Slightly more verbosely (using -v): 
[dtthp204]-> ~ 40> /usr/intel/pkgs/gcc/2.95.1/bin/g++ -v -shared -fpic -o libworld.sl my_helloworld.o
Reading specs from /usr/intel/pkgs/gcc/2.95.1/lib/gcc-lib/hppa1.1-hp-hpux10.20/2.95.1/specs
gcc version 2.95.1 19990816 (release)
 /usr/intel/pkgs/gcc/2.95.1/lib/gcc-lib/hppa1.1-hp-hpux10.20/2.95.1/collect2 -ldce -z -b -o libworld.sl -L/usr/intel/pkgs/gcc/2.95.1/lib/gcc-lib/hppa1.1-hp-hpux10.20/2.95.1 -L/usr/ccs/bin -L/usr/ccs/lib -L/usr/intel/pkgs/gcc/2.95.1/lib my_helloworld.o -lstdc++ -lm -lgcc -lgcc
/usr/ccs/bin/ld: DP relative code in file /usr/intel/pkgs/gcc/2.95.1/lib/gcc-lib/hppa1.1-hp-hpux10.20/2.95.1/libstdc++.a(iostream.o) - shared library must be position
    independent.  Use +z or +Z to recompile.
collect2: ld returned 1 exit status



> > I'm having trouble bottoming out on what the best way to fix this 
> > is.  Build libstdc++ by itself separately after the main build 
> > and reinstall it, using aCC and +Z?  
> 
> No, that definitely won't help, C++ compilers still don't produce
> link-compatible code.

Understood. 

I checked the gcc FAQ on gnu.org and found this: 

---
Installing gcc on HP-UX without a precompiled gcc binary is somewhat tedious.
- Get gcc-XXX (2.95.2) and the GNU binutils. 
- Unpack GCC and configure for C only and --without-gnu-as. Build and install. 
- Use this Compiler to build and install then binutils. 
- Make sure you have GNU as in your PATH before the HP-UX as 
  (i.e.   /usr/local/bin is before /usr/bin and /usr/ccs/bin). 
- Reconfigure gcc --with-gnu-as and for the languages you need. 
- Rebuild and install the final version.
- You may rebuild and reinstall binutils with this compiler afterwards.
---

Hmm. Could rebuliding binutils possibly be the key?  Has anyone else
gotten shared libs working correctly on HPUX?  I'm thinking there
are people out there who must have by this point.

-Rob


-- 
#include <sig.h>
------------------------------------------------------------------
Robert Nesius             rnesius@ichips.intel.com    503.264.2830





More information about the Gcc-help mailing list