Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!tut.cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!midway!aylmer.uchicago.edu!geyer From: geyer@aylmer.uchicago.edu (Charles Geyer) Newsgroups: comp.unix.ultrix Subject: Re: Trouble with cc/f77 Message-ID: <1991Feb23.221331.4218@midway.uchicago.edu> Date: 23 Feb 91 22:13:31 GMT References: <1991Jan24.001055.3069@ims.alaska.edu> <1991Jan24.194343.5054@morrow.stanford.edu> <1991Jan24.203050.6702@morrow.stanford.edu> Sender: news@midway.uchicago.edu (News Administrator) Organization: Department of Statistics Lines: 50 [I missed the beginning of the thread, I hope these attributions are correct] In article <1991Jan24.001055.3069@ims.alaska.edu Don Rice (fnddr@acad3.alaska.edu) writes: > A couple of cc/f77 problems have turned up (Ultrix 4.0/DS5000/Fortran 2.1).... > ... when trying to combine a main program written in C with a subroutine > written in Fortran, the Fortran built-in functions aren't found: > > cc -o prog main.c fortsub.o -lF77 -lU77 -lI77 -lm > ld: > Undefined: > sinf > cosf > sqrtf In article <1991Jan24.194343.5054@morrow.stanford.edu> farrell@tioga.Stanford.EDU (Phil Farrell) replies: > Is the C compiler even finding the libraries? As installed, Fortran 2.1 > libraries are in /usr/lib/cmplrs/f77, but the C compiler looks for > those -lF77 etc directives in /usr/lib. I created symbolic links > for libF77.a, libI77.a, and libU77.a from /usr/lib/cmplrs/f77 to /usr/lib > on my system to address this problem. > > Secondly, you realize that the linker only searches a library once for > any references on its current "unresolved" list. If a routine from one > library calls one from another library that has already been searched, > that will created an undefined reference. You might play with the > order of libraries on your command line, or even add another -l command > at the end to search the library a second time. My solution to this problem is the following LDFLAGS = -L/usr/lib/cmplrs/f77 LIBS = -lF77 -lI77 -lU77 -lm OBJS = prog.o foo.o baz.o prog : $(OBJS) $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) My question is this: What is the "offical" right way to do this, if any? Is there something in the DEC manuals about calling Fortran from C? Please don't tell me to rtfm, this is a Sun-only site here. I am trying to solve some problems for a friend and get myself ready for a move to a DEC-only site in September. Charles Geyer Department of Statistics University of Chicago geyer@galton.uchicago.edu Brought to you by Super Global Mega Corp .com