C subroutine calls from FORTRAN

still at usceast.UUCP still at usceast.UUCP
Thu Feb 19 03:16:49 AEST 1987


	Here is an interesting problem:

When I try to compile and link the following routine (and a few others
which are insignificant for this particular query), I get a bunch of
unresolved external reference messages from the linker. This is apparently
because when you call a routine from f77, an underscore (_) is appended to
the fcn identifier both in front (as cc does) and BEHIND. How does one get
around this problem ? Any ideas would be greatly appreciated.

FORTRAN program using the specified routines...

	c     PROGRAM MAIN
	      integer ovcnt
	      integer jmpbuf(10),rv
	      common /sjmp/ jmpbuf,rv
	      external onbrk
	      call trapov(50)
	      rv = 0
	      call setjmp(jmpbuf)
	      call sgset(2,onbrk)
	      call matlab(rv)
	      k = ovcnt(0)
	      if (k .gt. 0) write(6,13) k
	   13 format('total overflows ',i9/)
	      stop
	      end

The exact messages produced when executing the "link" command...


	f77 -o matlab unixsys.o lib.o mat.o handler.o -lm -lc

	Undefined:
	_setjmp_
	_sgset_
	_onbrk_

As you can see, there is something going on here. Apparently, the above
program worked just fine under BSD4.1 (or so it was claimed); and the above
routine was part of the original distribution of the MATLAB tape (for
"mainframes") dated May 1982. Any suggestions (of a friendly nature) will
be greatly appreciated.

In fact, I notice that if I try to link a C subroutine with a FORTRAN program,
I get the exact same situation (so perhaps there is no dependence on the fact
that I am trying to use some of the system C fcns).



More information about the Comp.unix.questions mailing list