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.
Jim and Tomas, > We've based our build for netcdf4 on > nc-config --flibs > > to give us the libraries needed to link netcdf to our f90 code, > that no longer works now. > > But there is a new nf-config so why can't nc-config --flibs just call > nf-config --libs so that I don't have to make another special case for > netcdf version handling? > > If I make the switch to use pkg-config do I have any assurance that you > will continue to support it? We really need some stability in the tools > we rely on. I fixed and checked in a version of nc-config.in that the configure script will process into a new nc-config script that uses nf-config, if it's installed, to provide the right output for the --flibs, --fflags, --fc, --has_f77, and --has_f90 options. It will be in the next release, but if you want to try it out, just get http://svn.unidata.ucar.edu/repos/netcdf/trunk/nc-config.in and rerun configure, make check, and make install. Thanks for your persistence in getting this problem solved. --Russ > On Wed, Mar 28, 2012 at 2:50 PM, Russ Rew <address@hidden> wrote: > > > Hi Thomas, > > > > > > shell$ nc-config --flibs > > > > -L/some/path/lib @NC_FLIBS@ > > > > > > Oh, I see ... there is nf-config now. I have to adapt my Makefile, then, > > > for another case. Now it would be rather smart if nc-config would call > > > nf-config transparently for fortran stuff, eh? Even better: What > > > exactly is the reason not to provide files for pkg-config instead? Now > > > we have two config scripts for NetCDF, I guess three with the C++ > > > interface. It gets messy and I wonder what for. > > > > > > But, well, putting a hint about nf-config in some docs would also be > > > nice... it may be obvious, but I was not looking for it; just trying > > > to get NetCDF re-installed quickly to get working Fortran module again > > > (because of non-existent binary compatibility even between versions of > > > the same compiler). > > > > The functionality is there, but as you've pointed out, it's not properly > > documented and it looks like there were bugs using pkg-config for > > netcdf-fortran. The pkg-config files for the netCDF 4.2 C and > > Fortran packages get installed when you invoke "make install", e.g. for > > version 4.2 of netcdf and netcdf-fortran: > > > > /usr/local/lib/pkgconfig: > > -rw-r--r-- 1 root root 315 Mar 27 12:45 netcdf-fortran.pc > > -rw-r--r-- 1 root root 305 Mar 26 12:37 netcdf.pc > > > > The C library pkg-config seems to work OK: > > > > $ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig > > $ pkg-config --cflags --libs netcdf > > -I/usr/local/include -L/usr/local/lib -lnetcdf > > > > I've just tidied-up the C pkg-config file and redone the Fortran file, > > by modifying the top-level files netcdf.pc.in and netcdf-fortran.pc.in > > in the snapshot releases for each package. I've also documented the use > > of pkg-config for the Fortran version 4.2 library with a couple of > > examples in the man4/netcdf-f77.texi and man4/netcdf-f90.texi files. > > > > Basically it's used like this: > > > > $ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig > > $ f90 myprogram.f90 -o myprogram `pkg-config --cflags --libs > > netcdf-fortran` > > > > where here `--cflags' means *compiler* flags and `libs' requests that > > the appropriate libraries be linked in, so it's different from the > > nf-config options of "fflags" and "flibs", but consistent with the > > pkg-config conventions. > > > > If you want to try these, you can get just the netcdf.pc.in and > > netcdf-fortran.pc.in files from our svn tree: > > > > http://svn.unidata.ucar.edu/repos/netcdf/trunk/netcdf.pc.in > > > > http://svn.unidata.ucar.edu/repos/netcdf-fortran/trunk/netcdf-fortran.pc.in > > > > Then put them in the top-level directories of the C and Fortran > > releases, configure, make check, and make install. The generated > > pkg-config files get installed in the ${prefix}/lib/pkgconfig directory. > > > > Thanks for pointing out the problems. Please let me know if you have > > other improvements to suggest. I wasn't able to figure out what was > > meant by > > > > > ... nc-config would call nf-config transparently for fortran stuff > > > > but I think pkg-config is a more scalable solution. > > > > --Russ > > > > > > -- > Jim Edwards > > CESM Software Engineering Group > National Center for Atmospheric Research > Boulder, CO > 303-497-1842