RE: [ncarg-talk] NCARG Compile errors, RH 8, RH 9 & Fedora 1 ?

From: Rick Grubin (grubin AT XXXXXX)
Date: Tue Apr 06 2004 - 15:48:32 MDT


Hi Robert

> This is the info on my 3 systems. I run up2date all the time on them!

Thanks for the output from your three hosts. It's helpful to know the
versions of GNU tools you have, and how they're configured. Regarding the
failure you're seeing:

> Making ./common/src/fontcap make[4]: Entering directory
> `/opt/NCARG/ncarg-4.3.1/common/src/fontcap'
>
> g77 -O -c cfaamn.f

Briefly, this Fortran source file contains the main program driver for the
font converter (note the statement PROGRAM CFAAMN in this file).

Once the individual source files are compiled, linking/loading is next,
and it fails with the "undefined reference" error:

> > g77 -O -o fontc cfaamn.o cfrdln.o cfwrit.o ffgttk.o ffinfo.o
> [...]
> > -L/opt/NCARG/v431/lib -L/usr/X11R6/lib -L/opt/NCARG/ncarg-4.3.1/hdf/lib -lg2c -lm
> > /usr/lib/gcc-lib/i386-redhat-linux/3.3.2/../../../crt1.o(.text+0x18):
> In function `_start': undefined reference to `main'

The occurrence of this error is "normal behavior" when a program loader
does not see (in source or object form) a Fortran "main" function -- a
PROGRAM statement, or the C "main()" equivalent. But we know that there
is a "main" (or PROGRAM) function for this program, as noted above.

When g77 compiles a program, it provides a procedure "MAIN__" and some
other, external object/library has the actual "main()" function (which
performs some basic startup housekeeping prior to invoking the user's
code) -- typical of C-based environments. In any Unix dev environment,
the file /usr/lib/crt1.o performs this function. These object
files/libraries are typically referred to as "run-time" libraries.

The file libg2c.a is typically used when mixing languages: that is,
combining C and Fortran source code in some manner. When g77 and libg2c.a
are used in conjunction, the implication is that your Fortran code does
not have a "main" function (or PROGRAM statement) -- it will come from
elsewhere (usually a C program source file).

The error you're seeing is caused by trying to link libg2c.a into the
produced binary executable. When the loader sees the symbol "main" that
exists in libg2c.a, it cannot be reconciled with the expected symbol
(again, "main") in /usr/lib/crt1.o).

The solution is to remove the "-lg2c -lm" text from the Makefile where the
command for loading is. If you added these libraries here specifically,
could you elaborate a bit on why you did so? Or were they added when you
configured your build environment?

-Rick.

--
Rick Grubin                     Visualization + Enabling Technologies
Scientific Computing Division   National Center for Atmospheric Research   
grubin@ucar.edu                 303.497.1832

_______________________________________________ ncarg-talk mailing list ncarg-talk@ucar.edu http://mailman.ucar.edu/mailman/listinfo/ncarg-talk



This archive was generated by hypermail 2b29 : Mon Apr 12 2004 - 11:03:33 MDT