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

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


> 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 

Since netCDF Fortran depends on netCDF C, which depends on HDF5, the above 

  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 
with .so extension in your /Users/Stefan/cool/lib directory), then you should 
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 
you have to either set the LD_LIBRARY_PATH environment variable (or 
for OSX) to include your lib directory, or use another method such as setting 
at link time.


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

NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.