problem linking FORTRAN sub in C prog

Mumit Khan khan at THOR.XRAYLITH.WISC.EDU
Mon Sep 3 04:01:42 AEST 1990


Hi,
I've trying to link a FORTRAN routine with a C program (I've done the
reverse w/out any problem), and facing a weird problem. Here's the
scenario: The FORTRAN routines (READLIB) opens and reads a direct access 
binary file and returns the result to the calling C routine. Then I use CC
as the driver to link all the object code together and there are two
undefined externals (even if I specify -lF77 -lI77 -lU77 on the linker
line). When I use F77 as the driver, I still get an undefined external,
only one this time. Here's the output:

:
: khan at thor ~/tran:42>cc -o test *.o -lF77 -lI77 -lU77 -lm
: ld:
: readlib.o: version stamp: 2.10, does not match ld's: 1.31
: Undefined:
: f_open0                     <---- Where is this defined ?????
: s_abort                     <---- This is libF77.a (why undefined?)
:
: khan at thor ~/tran:43>f77 -o test *.o -lm -lc
: ld:
: Undefined:
: s_abort                     <----- But this is in libF77.a????
:
: khan at thor ~/tran:44>nm readlib.o  <--- This is the FORTRAN routine.
: 00000400 T binary_
:          U do_fio
:          U do_lio
:          U do_uio
:          U e_rdue
:          U e_rsfe
:          U e_wsle
:          U f_clos
:          U f_open0            <----- f_open0
: 00000008 T readlib_
:          U s_cmp
:          U s_rdue
:          U s_rsfe
:          U s_wsle
:
: khan at thor ~/tran:45>nm /usr/lib/libF77.a | egrep f_open0
: khan at thor ~/tran:46>nm /usr/lib/libI77.a | egrep f_open0
: khan at thor ~/tran:47>nm /usr/lib/libU77.a | egrep f_open0
:
: khan at thor ~/tran:48>nm /usr/lib/libF77.a | egrep s_abort
:          U s_abort
:          U s_abort
:          U s_abort
: s_abort.o:
: 10000000 T s_abort
: 


Right now, I'm defining my own s_abort(), and using f77 as the driver to
make it work. Ugly, but I need it to run. The manuals tell me to use CC as
the driver (since MAIN is written in C), but then nothing works because of
f_open0. Also, note the version mismatch in the FORTRAN routine. I assume
it's not serious. Or, is it?

Any ideas? Am I missing something obvious? More info needed?
BTW, I'm running Ultrix 3.1c on a DS3100.

Help/pointers appreciated.

Mumit -- khan at xraylith.wisc.edu



More information about the Comp.unix.ultrix mailing list