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

[netCDF #NVZ-566012]: Linking to netcdf: static linking fails despite including all nc-config indicated libs



Hi Chris,

What happens when you try to compile your file *specifically* using the output 
from "nc-config --libs"? For example, compiling a test program using gcc on the 
command line as follows works (when using static libraries).

    $ gcc -o foo foo.c $(nc-config --libs)

The output from nc-config --libs is as follows:

    -L/usr/local/lib -lnetcdf -lhdf5_hl -lhdf5 -ldl -lm -lz -lcurl

Do you see the same error?

-Ward

> 
> Following-up:  I hadn¹t seen the webpage at
> 
> https://www.unidata.ucar.edu/software/netcdf/docs/getting_and_building_netc
> df.html#linking
> 
> . . .since I assumed from the title of the page that it was solely about
> building the NetCDF libraries, which I didn¹t need to do.  But I¹ve since
> discovered that subsection on linking, and it seems to suggest that one
> *does* need to link to HDF5, and to curl, zlib and libm, when building
> statically.  However, even this produced a whole raft of undefined
> reference errors; so far, I¹ve since had to add "-lssl -lidn -lssh
> -lpthread -ldl² to resolve many of them, and now I have hundreds of new
> ones from curl and ssl.  Is it really meant to be this complicated to do a
> static link against NetCDF4?
> 
> Thanks,
> 
> -c
> 
> 
> 
> --
> Chris Metzler
> 
> Research Physicist, Space Science Division
> Code 7633
> Naval Research Laboratory
> W  (202) 767-6166
> www.nrl.navy.mil
> 
> 
> 
> 
> 
> On 2/13/18, 5:22 PM, "Unidata netCDF Support"
> <address@hidden> wrote:
> 
> >
> >Metzler, Chris,
> >
> >Your Ticket has been received, and a Unidata staff member will review it
> >and reply accordingly. Listed below are details of this new Ticket.
> >Please make sure the Ticket ID remains in the Subject: line on all
> >correspondence related to this Ticket.
> >
> >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.
> >
> >    Ticket ID: NVZ-566012
> >    Subject: Linking to netcdf:  static linking fails despite including
> >all nc-config indicated libs
> >    Department: Support netCDF
> >    Priority: Normal
> >    Status: Open
> >
> >
> >
> >The NetCDF libraries are developed at the Unidata Program Center,
> >in Boulder, Colorado, funded primarily by the National Science Foundation.
> >
> >All support requests are handled by the development team. No dedicated
> >support staff are funded at this time. For this reason we cannot guarantee
> >response times, nor that we can resolve every support issue, although we
> >do our best to respond within 72 hours.
> >
> >It is in the nature of support requests that the same question is asked
> >many
> >times. We urge you to search the support archives for material relating to
> >your support request:
> >
> >http://www.unidata.ucar.edu/search.jsp?support&netcdf
> >
> >If you are having trouble building netCDF, please take a look at the
> >"Building NetCDF" page:
> >
> >http://www.unidata.ucar.edu/software/netcdf/docs/building.html
> >
> >or the (unfortunately somewhat out-of-date) NetCDF Build Troubleshooter
> >page:
> >
> >http://www.unidata.ucar.edu/software/netcdf/docs/troubleshoot.html
> >
> >Windows users should see the FAQ list:
> >
> >http://www.unidata.ucar.edu/software/netcdf/docs/faq.html#windows_netcdf4_
> >2
> >
> >Complete documentation (including a tutorial, and sample programs in C,
> >Fortran,
> >Java, and other programming languages) can be found on the netCDF
> >Documentation page:
> >
> >http://www.unidata.ucar.edu/software/netcdf/docs/
> >http://www.unidata.ucar.edu/software/netcdf/examples/programs/
> >
> >If you resolve your issue through one of these methods, please send a
> >reply to
> >this email, letting us know that you no longer need support. This will
> >help
> >us spend more time on netCDF development.
> >
> >Best regards,
> >
> >Unidata User Support
> >
> 
> 


Ticket Details
===================
Ticket ID: NVZ-566012
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.