[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

20030731: netCDF linking problem: undefined reference: `nf_open__'



Balaji,

> To: address@hidden
> From: Balaji Rajagopalan <address@hidden>
> Subject: request help with linking on linux
> Organization: UCAR/Unidata

The above message contained the following:

> I am running Redhat 9.0 and have netcdf-3.5.0 installed.
> I am trying to compile a fortran code with the following Makefile
> readncdf: read_netcdf.o ; pgf77 read_netcdf.o \
> -I/usr/local/netcdf-3.5.0/include \
> -L/usr/local/netcdf-3.5.0/lib -lnetcdf\ -
> o read_netcdf
> rm -f *.o
> ---
> it gives the following error message..
> ead_netcdf.o(.text+0x1a): In function `MAIN__':
> : undefined reference to `nf_open__'
...

I suspect that the problem exists because you are using the Portland
Group Fortran-77 compiler but the Fortran-77 interface of the netCDF
library was built assuming a different Fortran-77 compiler.  Different
Fortran compilers have different calling conventions; consequently, the
same Fortran compiler should be used on all relevant object modules of a
program -- including the object modules of any libraries.

You should either use the same Fortran-77 compiler that was assumed when
the netCDF library was built or use a netCDF library that assumes the
Portland Group Fortran-77 compiler.

To use the same Fortran-77 compiler that was assumed when the netCDF
library was built, look at the file "macros.make" in the top-level
source directory of the netCDF package.  Use the value of the macro
"FC" as your Fortran-77 compiler.

To use a netCDF library that assumes the Portland Group Fortran-77
compiler, do the following:

    1.  Go to the top-level source directory of the netCDF package.

    2.  Perform steps 3 through 5 described near the end of the file
        INSTALL.html.

    3.  Ensure that the environment variable FC is set to the absolute
        pathname of the Portland Group Fortran-77 compiler, e.g.,

            export FC=/opt/pgi/linux86/bin/pgf77

        or

            setenv FC /opt/pgi/linux86/bin/pgf77

        depending on your user-shell.

    4.  Perform steps 6 through 9 described near the end of the file
        INSTALL.html.

Note that, unless you take steps otherwise, you will overwrite your
current netCDF installation.

Regards,
Steve Emmerson