This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
>To: address@hidden >From: Samuel Richard Raisanen <address@hidden> >Subject: including the netcdf fortran library >Organization: Space Research, University of Michigan >Keywords: 199704171929.NAA27350 Hi Samuel, > I have downloaded and installed the netcdf library software. I am > having trouble getting the library correctly included. I am trying to run > the example.f file. Upon compiling it I get the following error: > undefined symbol (ncvrpt_, nccre_,...) first referenced in file > (example.o). I checked the include line (INCLUDE 'netcdf.inc') in the > file example.f and it appears correct. I have also tried to link > libnetcdf.a with example.f at compile time, but I still get these errors. I > have also made sure that I installed the correct jacket as per the > instructions in /fortran/README. What am I missing? The errors you are seeing are from the linker; they are not related to the netcdf.inc include file, which you have evidently included properly. Unless the netCDF library is installed in a standard directory where the linker always looks, you must use the -L and -l options to link an object file that uses the netCDF library. For example: f77 -o example example.o -L/usr/local/netcdf/lib -lnetcdf Alternatively, you could specify an absolute pathname for the library: f77 -o example example.o -l/usr/local/netcdf/lib/libnetcdf.a You should replace "/usr/local/netcdf/lib/" with wherever you really installed the library, or where it was left after you built it. The build process first builds the C library, then adds the Fortran library to it, so the library you built might be missing the Fortran part if you interrupted the build before it finished. Another way to tell how to invoke the Fortran compiler for netCDF programs is to invoke "make clean test" in the netcdf src/fortran/ directory, and observe how the Fortran test program is built from the make output. --Russ _____________________________________________________________________ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu