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.
Hi Lou, > Package Version: 4.1.3 > Operating System: Cygwin/W7 pro-64 bit > Hardware: Xeon > Description of problem: > > Downloaded netcdf-4.1.3.tar.gz; ran > ./configure --prefix=/usr/local --disable-netcdf-4 > make check > make install > > Got successfully installed message. Then ran > > gfortran test_prog.f90 -I/usr/local/include /usr/local/lib/libnetdf.a One problem might just be the typo of specifying "libnetdf.a" instead of "libnetcdf.a", but assuming you actually got that right when you tried it, maybe you should be linking to the shared libraries rather than the static libraries. > Got message: > /tmp/ccmrh3C6.o:test_prog.f90:(text+0x6f): undefined reference to > '___netcdf_MOD_nf90_inq_libvers' > collect2: ld returned 1 exit status > > /usr/local/include does contain NETCDF.mod > Any help would be appreciated. By default, versions 4.1.3 and later install shared libraries. When shared libraries are used, netCDF needs to create a separate library for Fortran instead of combining the C and Fortran libraries together into one static library. Therefor, you need to tell gfortran where to look for the Fortran functions, which will be in a library with the name "libnetcdff". So first try linking with the shared libraries, using gfortran test_prog.f90 -I/usr/local/include -L/usr/local/lib -lnetcdff -lnetcdf You can also link with the static libraries by instead using gfortran test_prog.f90 -I/usr/local/include /usr/local/lib/libnetcdff.a /usr/local/lib/libnetcdf.a Finally, if you don't want the shared libraries built but want to always use static libraries, you can rebuild with the configure option --disable-shared and then reinstall, but you might have to uninstall the shared libraries from the previous build to make sure they aren't used. But shared libraries have some advantages over static libraries, see: http://www.unidata.ucar.edu/netcdf/docs/faq.html#Shared%20Libraries --Russ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: QYJ-726116 Department: Support netCDF Priority: Normal Status: Closed