Ticket #4424 (closed defect: fixed)

Opened 17 months ago

Last modified 16 months ago

configure script does not support static netcdf build

Reported by: etourigny Owned by: etourigny
Priority: normal Milestone: 1.9.1
Component: GDAL_Raster Version: unspecified
Severity: normal Keywords: netcdf, configure
Cc: kyngchaos@…, kyle

Description

Current configure script only supports a shared netcdf build, which does not require additional linking parameters and is also the default for most linux distribution packaging.

William Kyngesburye reported on the gdal-dev list problems in building gdal on osx with a static netcdf build, with hdf5 and curl:

OK, I have NetCDF now with HDF4/5 & DAP.  Now configure problems again (again, netcdf is static library, as are HDF4, HDF5 and DAP):

My netcdf needs curl (it defaults to using curl), but GDAL doesn't test netcdf with that (curl is tested much later).

Netcdf4 also needs some symbols from libhdf5_hl, but this is not checked for. 

...

OK, looking good, after patching configure to work around netcdf problems mentioned.

nc-config --libs should give the libs necessary for a particular netcdf build, and resolve the problems stated above.

Can William (what is your username?) provide the patch used to resolve the configure problems here?

Also, is it a requirement or limitation to have static builds on osx?

Attachments

patch-4424-1.txt Download (4.6 KB) - added by etourigny 16 months ago.
patch for configure.in
configure.in Download (116.0 KB) - added by etourigny 16 months ago.
configure.1.gz Download (154.3 KB) - added by etourigny 16 months ago.
modified configure (using autoconf 2.67)
patch-4424-2.txt Download (13.5 KB) - added by etourigny 16 months ago.
configure.2.in Download (115.8 KB) - added by etourigny 16 months ago.
configure.2.gz Download (154.5 KB) - added by etourigny 16 months ago.

Change History

Changed 17 months ago by etourigny

related ticket which I have recently closed (perhaps prematurely...) #3154

A simple fix would be to add the output of 'nc-config --libs' to LIBS, which should work for both static and shared netcdf-4. When nc-config is not found, use previous behaviour.

Changed 17 months ago by etourigny

William, I am not sure if I understand the problems you encountered, is it just that the necessary libraries are not checked for, or some compilation or linking problem?

I build a static netcdf and was able to compile and run the autotests fine without any modifications to configure.

Changed 17 months ago by kyngchaos

When I build HDF5 (static), I get libhdf5 and libhdf5_hl. When I build netcdf (static) with HDF5 support, it needs symbols in both those. Now, when configuring GDAL for netcdf and it tests for HDF5 support in netcdf, it does a link test with just libhdf5 (whatever was added to LIBS when HDF5 was checked) and I get missing symbol errors (and those missing symbols are in libhdf5_hl).

Undefined symbols for architecture x86_64:
  "_H5DSiterate_scales", referenced from:
      _nc4_rec_read_vars in libnetcdf.a(libnetcdf4_la-nc4file.o)
  "_H5DSis_scale", referenced from:
      _nc4_rec_read_vars in libnetcdf.a(libnetcdf4_la-nc4file.o)
  "_H5DSget_scale_name", referenced from:
      _nc4_rec_read_vars in libnetcdf.a(libnetcdf4_la-nc4file.o)
  "_H5DSget_num_scales", referenced from:
      _nc4_rec_read_vars in libnetcdf.a(libnetcdf4_la-nc4file.o)
  "_H5DSdetach_scale", referenced from:
      _rec_detach_scales in libnetcdf.a(libnetcdf4_la-nc4hdf.o)
      _nc4_rec_write_metadata in libnetcdf.a(libnetcdf4_la-nc4hdf.o)
  "_H5DSattach_scale", referenced from:
      _rec_reattach_scales in libnetcdf.a(libnetcdf4_la-nc4hdf.o)
      _nc4_rec_write_metadata in libnetcdf.a(libnetcdf4_la-nc4hdf.o)
  "_H5DSset_scale", referenced from:
      _nc4_rec_write_metadata in libnetcdf.a(libnetcdf4_la-nc4hdf.o)

For this, I just just added -lhdf5_hl to the test for HDF5 so that it will be in the netcdf test.

Same goes for curl, the test for nc_open in -lnetcdf doesn't know netcdf4 needs curl (a default configuration).

For this I added -lcurl to the netcdf test.

But for both, probably the nc-config --libs method would be better - it has all the necessary linking flags (including -L flags). I can easily add the netcdf/bin to the PATH before configuring.

Changed 17 months ago by etourigny

I will try to work on this in the next few days and post here a patch for testing. Will probably not make it into 1.9.0 unless there is a new RC (which is unlikely).

Changed 16 months ago by etourigny

patch for configure.in

Changed 16 months ago by etourigny

Changed 16 months ago by etourigny

modified configure (using autoconf 2.67)

Changed 16 months ago by etourigny

  • cc kyle added

Please test the attached patch (against svn trunk/1.9.0) or complete configure.in, or the generated configure script.

I have tested against static and shared netcdf-4.1.3 builds as well as netcdf-3.6.3 under ubuntu 11.04. It uses nc-config if found, and if not falls back to previous behaviour. Probably does not work for a static build of netcdf-3.6.3 as there is not nc-config available in older versions.

kyle - can you please test that this does not break configuration and building in fedora?

Changed 16 months ago by kyle

Etienne, I will test tomorrow, and post results.

Changed 16 months ago by kyle

Etienne, configure script picks up my system and user defined netcdf shared libs. Seems good to me.

Changed 16 months ago by kyngchaos

sorry for the wait - the patch works for my case. Just add netcdf/bin to my PATH and configure finds nc-config and gdal links without error.

Changed 16 months ago by etourigny

  • milestone changed from 1.9.0 to 1.9.1

William, thanks for your help.

I have a slightly modified version, can you please test again before I commit?

Attaching patched configure.in and configure.

Changed 16 months ago by etourigny

Changed 16 months ago by etourigny

Changed 16 months ago by etourigny

Changed 16 months ago by kyngchaos

Still works.

Changed 16 months ago by etourigny

  • status changed from new to closed
  • resolution set to fixed

fixed in trunk (r23794) and 1.9 (r23795)

Note: See TracTickets for help on using tickets.