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

[netCDF #CAF-785846]: cygwin/gfortran 4.6/netcdf-4.1.1 link problem

Hi Rich,

> We've spent hours on this, so hopefully you can spend 1 minute on this
> and provide the answer! ;-)
> Make check shows the tests in nf_test working just fine, but when we
> try to compile our own Fortran program
> $ gfortran -o  test  GRIDinc_Generator.f90
> -I/usr/local/gfortran/include -L/usr/local/gfortran/lib -lnetcdf
> we get lots of statements like:
> /usr/local/gfortran/lib/libnetcdf.a(netcdf4.o): In function 
> `nf90_get_var_any':
> /usr/local/netcdf-4.1.1/f90/netcdf4_func.f90:584: undefined reference
> to `_nf_get_vars_'
> /usr/local/gfortran/lib/libnetcdf.a(netcdf4.o): In function 
> `nf90_put_var_any':
> /usr/local/netcdf-4.1.1/f90/netcdf4_func.f90:562: undefined reference
> to `_nf_put_vars_'

Is there a separate library installed in /usr/local/gfortran/lib/
named libnetcdff.a (note the double "ff")?  If so, you need to use

  -L/usr/local/gfortran/lib -lnetcdff -lnetcdf

to link with both the separate Fortran library and C library.

Also, if you installed nc-config along with the other netCDF utilities
like ncgen and ncdump, you should look at the output from

  nc_config --flibs

which will show how Fortrna programs should be linked with your

If none of these solve the problem, please let us know ...


Russ Rew                                         UCAR Unidata Program
address@hidden                      http://www.unidata.ucar.edu

Ticket Details
Ticket ID: CAF-785846
Department: Support netCDF
Priority: Normal
Status: Closed