Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!mit-eddie!genrad!decvax!decwrl!hplabs!hp-sdd!ncr-sd!ncrcae!usceast!still From: still@usceast.UUCP Newsgroups: comp.lang.fortran,comp.unix.questions Subject: C subroutine calls from FORTRAN Message-ID: <2324@usceast.UUCP> Date: Wed, 18-Feb-87 12:16:49 EST Article-I.D.: usceast.2324 Posted: Wed Feb 18 12:16:49 1987 Date-Received: Fri, 20-Feb-87 04:41:06 EST Reply-To: still@usceast.UUCP (Bert Still) Organization: Csci Dept, U of S. Carolina, Columbia Lines: 47 Xref: utgpu comp.lang.fortran:63 comp.unix.questions:1111 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).