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

[netCDF #PUN-322109]: nc-config issue when installing both shared and static libraries

Hi Davide,

> We've installed netcdf in Yellowstone with both shared and static
> libraries. When querying nc-config for the libraries, one gets what follows:
> $ nc-config --libs
> -L/glade/apps/opt/netcdf/4.2/gnu/4.7.2/lib -lnetcdf
> Which is perfectly fine for an user compiling programs against the
> shared library (our RPATH takes care of the HDF5 dependency). However,
> if the user is compiling statically, this output is incomplete: it let
> them resolve the static archive which we installed in the same
> directory, but it does not let them resolve the HDF5 dependencies.
> I believe a --static-libs or something of that flavor should be added to
> nc-config to cover this use case, but maybe there is already a way.
> Please advice.

We distribute recent versions of the netCDF C and Fortran libraries
with support for "pkg-config", which is a general version of
package-specific scripts like nc-config and nf-config that outputs
information for shared libraries by default, but can optionally output
library information suitable for static linking.

You would use pkg-config much like nc-config, to help compile and link
an application, for example:

  $ export PKG_CONFIG_PATH=/opt/lib/pkgconfig
  $ gcc -o test test.c $(pkg-config --libs --cflags netcdf)

Note: "cflags" here means "compiler flags" not "C flags", so you could
use the same command for gfortran as gcc:

  $ gfortran -o test test.c $(pkg-config --libs --cflags netcdf-fortran)

You may want to check if you have the pkg-config command installed and
look at the documentation to make sure it supports the --static

Here's examples of the output of pkg-config with and without --static
on my platform, resulting from a standard "sudo make install":

  $ pkg-config --cflags --libs netcdf
  -I/usr/local/include  -L/usr/local/lib -L/machine/russ/installs/hdf5_1811/lib 
-L/opt/lib -lnetcdf -lhdf5_hl -lhdf5 -lm -lz -lcurl  
  $ pkg-config --static --cflags --libs netcdf
  -I/usr/local/include  -L/usr/local/lib -L/machine/russ/installs/hdf5_1811/lib 
-L/opt/lib -lnetcdf -lhdf5_hl -lhdf5 -lm -lz -lcurl  
  you have mail in /var/spool/mail/russ
  $ pkg-config --cflags --libs netcdf-fortran
  -I/usr/local/include  -L/usr/local/lib -lnetcdff  
  $ pkg-config --static --cflags --libs netcdf-fortran
  -I/usr/local/include  -L/usr/local/lib -L/machine/russ/installs/hdf5_1811/lib 
-L/opt/lib -lnetcdff -lnetcdf -lhdf5_hl -lhdf5 -lm -lz -lcurl  


> Regards,
> Davide Del Vento,
> NCAR Computational & Information Services Laboratory
> Consulting Services Software Engineer
> http://www2.cisl.ucar.edu/uss/csg/
> SEA Chair http://sea.ucar.edu/
Russ Rew                                         UCAR Unidata Program
address@hidden                      http://www.unidata.ucar.edu

Ticket Details
Ticket ID: PUN-322109
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.