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

[netCDF #HBB-707489]: Error When Building NetCDF4.3.1



Steve,

> gfortran -o nc nc.f95 -L/Users/Stefan/cool/lib -I/Users/Stefan/local/include 
> -I/Users/Stefan/cool/include -lhdf5 -lhdf5_hl -lz -lnetcdf

I should have noticed that the order in which the libraries are linked above is 
wrong.

Since netCDF Fortran depends on netCDF C, which depends on HDF5, the above 
should 
be:

  gfortran -o nc nc.f95 -L/Users/Stefan/cool/lib -I/Users/Stefan/local/include 
-I/Users/Stefan/cool/include -lnetcdff -lnetcdf -lhdf5_hl -lhdf5 -lz 

But if hdf5 and the netCDF-C library are available as shared libraries 
(appearing 
with .so extension in your /Users/Stefan/cool/lib directory), then you should 
be 
able to link more simply, with just

  gfortran -o nc nc.f95 -L/Users/Stefan/cool/lib -I/Users/Stefan/local/include 
-I/Users/Stefan/cool/include -lnetcdff

Note that to run the resulting "nc" program when it's linked to shared 
libraries, 
you have to either set the LD_LIBRARY_PATH environment variable (or 
DYLD_LIBRARY_PATH 
for OSX) to include your lib directory, or use another method such as setting 
RPATH
at link time.

--Russ

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



Ticket Details
===================
Ticket ID: HBB-707489
Department: Support netCDF
Priority: Normal
Status: Closed