Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!ncar!gatech!prism!scott From: scott@prism.gatech.EDU (Scott Holt) Newsgroups: comp.unix.aix Subject: Re: C + FORTRAN + getenv() (Was: NCAR running under AIX 3.1 update 3003) Message-ID: <26541@hydra.gatech.EDU> Date: 17 Apr 91 21:01:28 GMT References: <1991Apr17.192557.5133@batcomputer.tn.cornell.edu> Organization: Georgia Institute of Technology Lines: 28 In article <1991Apr17.192557.5133@batcomputer.tn.cornell.edu> kakazu@theory.tn.cornell.edu (Gary Kakazu) writes: > >It appears that if a Fortran program calls a C program, and the C >program calls the routine getenv, the program crashes. If I comment >out getenv in the routines that call it, and pass the GRAPHCAP & FONTCAP >info on the command line, the example program works fine. > You are essentially correct - there is a problem. However, it is possible to mix FORTRAN and C with a C routine that calls getenv - just make sure you link in the C runtime library... as in: test1: $(COBJS) $(FOBJS) xlf $(FFLAGS) -o test1 $(COBJS) $(FOBJS) -lc Ordinarily the linker will satisfy the reference to getenv from the FORTRAN runtime library. Now, there is a problem if BOTH the FORTRAN and C routines call their respective getenvs - There can only be one getenv symbol in the final bound product so someone looses. -Scott -- This is my signature. There are many like it, but this one is mine. Scott Holt Internet: scott@prism.gatech.edu Georgia Tech UUCP: ..!gatech!prism!scott Office of Information Technology, Technical Services