OPENDAP/bes

When gdal not present, configure does not complain, but build fails (same with hdf5)

captainkirk99 opened this issue · 0 comments

Building without gdal, I see that configure.ac correctly determined that gdal was not present:

configure: Looking for GDAL.
checking for gdal-config... no
configure: WARNING: gdal-config does not exist or it is not an exectuable file
no

However, the build then breaks:

DapFunctions.cc:29:10: fatal error: gdal.h: No such file or directory
   29 | #include <gdal.h>   // needed for scale_{grid,array}
      |          ^~~~~~~~
compilation terminated.

This is because DapFunctions includes gdal.h in an unprotected way:

#include "config.h"

#include <iostream>

#include <gdal.h>   // needed for scale_{grid,array}

#include <ServerFunctionsList.h>

I tried wrapping this in ifdefs for HAVE_GDAL, and that helps, but eventually we fail like this:

In file included from DapFunctions.cc:55:
ScaleGrid.h:72:13: error: ‘GDAL_GCP’ was not declared in this scope
   72 | std::vector<GDAL_GCP> get_gcp_data(libdap::Array *x, libdap::Array *y, int sample_x = 1, int sample_y = 1);
      |             ^~~~~~~~
ScaleGrid.h:72:21: error: template argument 1 is invalid
   72 | std::vector<GDAL_GCP> get_gcp_data(libdap::Array *x, libdap::Array *y, int sample_x = 1, int sample_y = 1);
      |                     ^
ScaleGrid.h:72:21: error: template argument 2 is invalid

So either more code needs to be protected, or gdal needs to be required, and configure.ac should error out if gdal is not found.

Similarly, if HDF5 is not found, the build proceeds, then errors like this:

make[5]: Entering directory '/home/ed/bes/modules/dmrpp_module'
g++ -DHAVE_CONFIG_H -I. -I../..  -I../.. -I../../dispatch -I../../dap -I../../http -I/usr/include/libdap -I/usr/include/libxml2 -I/usr/local/opt/openssl/include -DMODULE_NAME=\"dmrpp_module\" -DMODULE_VERSION=\"1.1.2\"  -I./../hdf5_handler -I/include -Wno-vla-extension -g -O2 --pedantic --std=c++11 -MT build_dmrpp-build_dmrpp.o -MD -MP -MF .deps/build_dmrpp-build_dmrpp.Tpo -c -o build_dmrpp-build_dmrpp.o `test -f 'build_dmrpp.cc' || echo './'`build_dmrpp.cc
build_dmrpp.cc:40:10: fatal error: H5Ppublic.h: No such file or directory
   40 | #include <H5Ppublic.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
ma