Opened 7 years ago

Closed 7 years ago

#4424 closed defect (fixed)

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 Shannon

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 (6)

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

Download all attachments as: .zip

Change History (17)

comment:1 Changed 7 years 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.

comment:2 Changed 7 years 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.

comment:3 Changed 7 years 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.

comment:4 Changed 7 years 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 7 years ago by etourigny

Attachment: patch-4424-1.txt added

patch for configure.in

Changed 7 years ago by etourigny

Attachment: configure.in added

Changed 7 years ago by etourigny

Attachment: configure.1.gz added

modified configure (using autoconf 2.67)

comment:5 Changed 7 years ago by etourigny

Cc: Kyle Shannon 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?

comment:6 Changed 7 years ago by Kyle Shannon

Etienne, I will test tomorrow, and post results.

comment:7 Changed 7 years ago by Kyle Shannon

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

comment:8 Changed 7 years 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.

comment:9 Changed 7 years ago by etourigny

Milestone: 1.9.01.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 7 years ago by etourigny

Attachment: patch-4424-2.txt added

Changed 7 years ago by etourigny

Attachment: configure.2.in added

Changed 7 years ago by etourigny

Attachment: configure.2.gz added

comment:10 Changed 7 years ago by kyngchaos

Still works.

comment:11 Changed 7 years ago by etourigny

Resolution: fixed
Status: newclosed

fixed in trunk (r23794) and 1.9 (r23795)

Note: See TracTickets for help on using tickets.