[net.lang.f77] using ioinit

winograd@nbires.UUCP (Steve Winograd) (04/06/84)

Compiling a program which calls ioinit (3f) on my 4.2bsd system with:
	f77 test.f
resulted in ld complaining about undefined symbols _i_len, _i_indx, _lnblnk_,
_s_cmp, and _s_copy.  Why?

1. ioinit is written in f77, not in c like all the other library routines.
2. the compiled code for ioinit calls the above-mentioned external symbols.
3. ioinit is in libI77.a and the externals it needs are in libF77.a.
4. f77 presents object files to ld in the order:
        /lib/crt0.o test.o -lF77 -lI77 -lU77 -lm -lc
   so libI77.a is searched after libF77.a.  Any of the libF77 routines which
   ioinit calls but which are not referenced by the user program will be
   unsatisfied because libF77.a is not searched again after libI77.a.

I got around the problem by adding "-lI77" to the end of the f77 command:
        f77 test.f -lI77
This makes f77 present object files to ld in the order:
        /lib/crt0.o test.o -lI77 -lF77 -lI77 -lU77 -lm -lc
so that libI77.a is searched both before and after libF77.a.  All the
external references in ioinit are now satisfied, but there is the extra
overhead of searching libI77.a twice.

Moving ioinit.o from libI77.a to libF77.a would be a more efficient solution,
but I hesitate to tinker with the structure of the libraries.  Does anyone
know of a better solution to this problem?

				Steve Winograd
				{ucbvax|hao|allegra}!nbires!winograd