Davide, > Thanks for the quick answer. Unfortunately, this does not work properly > for us: > > $ ls -1 /glade/apps/opt/netcdf/4.2/intel/12.1.4/lib/ > libnetcdf.a > libnetcdf_c++4.a > libnetcdf_c++4.la > libnetcdf_c++4.so > libnetcdf_c++4.so.1 > libnetcdf_c++4.so.1.0.2 > libnetcdf_c++.a > libnetcdf_c++.la > libnetcdf_c++.so > libnetcdf_c++.so.4 > libnetcdf_c++.so.4.2.0 > libnetcdff.a > libnetcdff.la > libnetcdff.so > libnetcdff.so.5 > libnetcdff.so.5.3.1 > libnetcdf.la > libnetcdf.so > libnetcdf.so.7 > libnetcdf.so.7.2.0 > pkgconfig > > $ ls -1 /glade/apps/opt/netcdf/4.2/intel/12.1.4/lib/pkgconfig/ > netcdf-cxx4.pc > netcdf-fortran.pc > netcdf.pc > > $ echo $PKG_CONFIG_PATH > /glade/apps/opt/netcdf/4.2/intel/12.1.4/lib/pkgconfig/ > > $ pkg-config --static --cflags --libs netcdf > -I/glade/apps/opt/netcdf/4.2/intel/12.1.4/include > -L/glade/apps/opt/netcdf/4.2/intel/12.1.4/lib -lnetcdf > > $ nm /glade/apps/opt/netcdf/4.2/intel/12.1.4/lib/libnetcdf.a | grep hdf > U nc4_rec_find_hdf_type > 0000000000002a20 t read_hdf5_att > libnetcdf4_la-nc4hdf.o: > 0000000000002730 T nc4_get_hdf_typeid > 00000000000005c0 T nc4_rec_find_hdf_type > 0000000000002680 T nc4_get_hdf4_vara > U nc4_get_hdf_typeid > > Any insights in why this may be broken? Checking more carefully, it looks like the "pkg-config --static --libs" solution didn't work for me either, for the netCDF C library. I got the same output whether I used "--static" or not. It did seem to work for the netCDF Fortran library, however. The suggestion to add a "--static" flag to nc-config was made some time ago, and discussed on the netcdfgroup mailing list: http://www.unidata.ucar.edu/mailing_lists/archives/netcdfgroup/2011/msg00315.html but without resolution. I think fixing this with pkg-config for the netCDF C library would require that HDF5 ship with pkg-config support, which it doesn't currently. I'm not sure what's needed to add a "--static-libs" flag to nc-config, but we'll look into it when we can. A temporary workaround would be to just modify the nc-config shell script locally to support this functionality, though I know that's not a good long-term solution ... --Russ > Thanks and Regards, > Davide Del Vento, > NCAR Computational & Information Services Laboratory > Consulting Services Software Engineer > http://www2.cisl.ucar.edu/uss/csg/ > > On 07/12/2013 02:03 PM, Unidata netCDF Support wrote: > > 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 > > option. > > > > 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 > > > > --Russ > > > >> 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 > > > > 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.