[comp.lang.fortran] Help me with make-ing f2c on a Sparcstation

ajayshah@almaak.usc.edu (Ajay Shah) (10/28/90)

I tried a lot of things without success.  Each attempt generated 
a different set of errors, what is shown below is the "best"
I could do.

Does someone know a recipe for make-ing a working f2c system on a Sun?

---------------------------------------------------------------------------
FIRST SHOWING YOU THE FORTRAN SOURCE:
[max 4] cat main.f
        x = 0.0
        call junk(x)
        write(6, *) x
        stop
        end
[max 5] cat junk.f
        subroutine junk(x)
        real y
        y = x
        y = y + 1.0
        x = y
        return
        end

PROVE THE FORTRAN WORKS:
[max 6] f77 main.f junk.f
main.f:
main.f:
 MAIN:
junk.f:
junk.f:
        junk:
Linking:
[max 7] a.out
    1.00000

RUN SOURCE THROUGH F2C:
[max 8] f2c < main.f > main.c
   MAIN:
[max 9] f2c < junk.f > junk.c
   junk:
[max 10] cc -c junk.c -lF77 -lI77 -lm -lc
[max 11] cc main.c junk.o -lF77 -lI77 -lm -lc
ld: Undefined symbol
   _MAIN_
---------------------------------------------------------------------------

Thanks!

-- 
_______________________________________________________________________________
Ajay Shah, (213)734-3930, ajayshah@usc.edu
                              The more things change, the more they stay insane.
_______________________________________________________________________________

staff@cadlab.sublink.ORG (Alex Martelli) (11/02/90)

ajayshah@almaak.usc.edu (Ajay Shah) writes:
	...
>Does someone know a recipe for make-ing a working f2c system on a Sun?

I believe the problem is that you should make and use the libraries
that go with f2c, rather than the Fortran runtime libraries from Sun,
which are similar but NOT identical to those.
-- 
Alex Martelli - CAD.LAB s.p.a., v. Stalingrado 45, Bologna, Italia
Email: (work:) staff@cadlab.sublink.org, (home:) alex@am.sublink.org
Phone: (work:) ++39 (51) 371099, (home:) ++39 (51) 250434; 
Fax: ++39 (51) 366964 (work only), Fidonet: 332/401.3 (home only).

bill@uhura1.uucp (Bill Wade) (11/02/90)

In article <27757@usc> ajayshah@almaak.usc.edu (Ajay Shah) writes:
>
>I tried a lot of things without success.  Each attempt generated 
>a different set of errors, what is shown below is the "best"
>I could do.
>
>Does someone know a recipe for make-ing a working f2c system on a Sun?
>
> (... good sample program omitted ...)
>
>[max 11] cc main.c junk.o -lF77 -lI77 -lm -lc
>ld: Undefined symbol
>   _MAIN_

You probably managed to use the libF77.a from sun fortran 1.3.  This
is normally located in /usr/lang/SC0.0, and got included because your
environment variable LD_LIBRARY_PATH said to.

The sun library expects the fortran main to be called '_MAIN_'.  The
f2c version of libF77.a expects the fortran main to be called
'_MAIN__'.  To be sure of getting the right libraries, give them a
distinctive name, like libFf2c.a and libIf2c.a, and link with

  'cc ... -L<directory containing f2c libraries> -lFf2c -lIf2c ...'

Hope this helps.