Operating System - HP-UX
1829347 Members
4738 Online
109991 Solutions
New Discussion

Linking program with libraries

 
Leif Halvarsson_2
Honored Contributor

Linking program with libraries

I get a list of 14 unsatisfied externals when I try to link a program with two subroutine-libraries. If I, as a test, omit the libraries the list will be about 75 unsatisfied externals.
It seems (to me) that the linker manages to find some subroutines but not all. The missing subroutines are referenced from either the main program or one of the libraries.
The program and the library subroutines are written in Fortran77 or C.

Compiling of library subroutine:
f90 -c -O -K -DAportable +U77 +ppu -o abbcor.o abbcor.F
cc -c -O -DAportable -Aa -D_HPUX_SOURCE -D_NO_PROTO -DSYSV -I/usr/include/X11R5 -o tsdrve.o tsdrve.c

Making the libraries:
ar rv libjack.a abbcor.o
ar rv c08.a tsdrve.o
ranlib libjack.a

Linking program:
f90 -Wl,-aarchive_shared -L/usr/lib/X11R5 -lm -O -o jackal jackal.o libjack.a c08.a
3 REPLIES 3
H.Merijn Brand (procura
Honored Contributor

Re: Linking program with libraries

why not 'ranlib c08.a' ?

Hmm, shared archives requested, static archives made ...


f90 -c -O .... +Z blah.F
cc -c -O .... +Z -o foo.c
ld -b -o blah.sl blah.o
ld -b -o foo.sl foo.o

f90 -L. -L/usr/... -o jackal jackal.o -lblah -lfoo
Enjoy, Have FUN! H.Merijn
H.Merijn Brand (procura
Honored Contributor

Re: Linking program with libraries

Last had -o too many, soory ...

f90 -c -O .... +Z blah.F
cc -c -O .... +Z foo.c
ld -b -o blah.sl blah.o
ld -b -o foo.sl foo.o

f90 -L. -L/usr/... -o jackal jackal.o -lblah -lfoo
Enjoy, Have FUN! H.Merijn
Leif Halvarsson_2
Honored Contributor

Re: Linking program with libraries

Hi!
Thank you procura for the answer!
There still is something wrong, however...
I have recompiled all routines in both libraries with the +Z option both for f90 and cc compilers and I have changed the extension for the libraries to .sl (instead of .a) and I use "ld -b -o" (instead of "ar rv") to enter the subroutines into the libraries, but now no library subroutine at all is loaded in the program, at least there is a very long list of unsatisfied externals.
I have tried to load the program with f90 or aCC (even if there are no C++ routines in this program) with the same result.