isciences / exactextract

Fast and accurate raster zonal statistics
Apache License 2.0
258 stars 33 forks source link

Build fails on Ubuntu Noble #119

Closed whatnick closed 4 months ago

whatnick commented 4 months ago

We are attempting to upgrade the base distribution of our containers to Ubuntu Noble. Using the latest g++ build tools exactextract has trouble using the cstdint typedefs. The first error is as below. I have attempted to import cstdint in a few headers and build can progress. Perhaps failing early using a CMake g++ max version constraint will help.

5.977 [  3%] Building CXX object CMakeFiles/exactextract_gdal.dir/src/gdal_raster_wrapper.cpp.o
6.246 In file included from /exactextract/src/gdal_raster_wrapper.h:18,
6.246                  from /exactextract/src/gdal_raster_wrapper.cpp:17:
6.246 /exactextract/src/raster.h:135:55: error: 'int8_t' is not a member of 'std'; did you mean 'wint_t'?
6.246   135 |     void set_mask(std::unique_ptr<AbstractRaster<std::int8_t>> mask)
6.246       |                                                       ^~~~~~
6.246       |                                                       wint_t
6.246 /exactextract/src/raster.h:135:55: error: template argument 1 is invalid
6.246 /exactextract/src/raster.h:135:61: error: template argument 1 is invalid
6.246   135 |     void set_mask(std::unique_ptr<AbstractRaster<std::int8_t>> mask)
6.246       |                                                             ^~
6.246 /exactextract/src/raster.h:135:61: error: template argument 2 is invalid
6.247 /exactextract/src/raster.h:256:41: error: 'int8_t' is not a member of 'std'; did you mean 'wint_t'?
6.247   256 |     std::unique_ptr<AbstractRaster<std::int8_t>> m_mask;
6.247       |                                         ^~~~~~
6.247       |                                         wint_t
6.247 /exactextract/src/raster.h:256:41: error: template argument 1 is invalid
6.247 /exactextract/src/raster.h:256:47: error: template argument 1 is invalid
6.247   256 |     std::unique_ptr<AbstractRaster<std::int8_t>> m_mask;
6.247       |                                               ^~
6.247 /exactextract/src/raster.h:256:47: error: template argument 2 is invalid
...
6.259 /exactextract/src/raster_source.h:53:42: error: template argument 1 is invalid
6.259    53 |     mutable std::unique_ptr<RasterVariant> m_empty;
6.259       |                                          ^
6.259 /exactextract/src/raster_source.h:53:42: error: template argument 2 is invalid
6.262 /exactextract/src/gdal_raster_wrapper.h:65:5: error: 'RasterVariant' does not name a type; did you mean 'RasterView'?
6.262    65 |     RasterVariant read_box(const Box& box) override;
6.262       |     ^~~~~~~~~~~~~
6.262       |     RasterView
6.266 /exactextract/src/gdal_raster_wrapper.cpp:70:1: error: 'RasterVariant' does not name a type; did you mean 'RasterView'?
6.266    70 | RasterVariant
6.266       | ^~~~~~~~~~~~~
6.266       | RasterView
6.317 gmake[2]: *** [CMakeFiles/exactextract_gdal.dir/build.make:90: CMakeFiles/exactextract_gdal.dir/src/gdal_raster_wrapper.cpp.o] Error 1
6.317 gmake[1]: *** [CMakeFiles/Makefile2:880: CMakeFiles/exactextract_gdal.dir/all] Error 2
6.317 gmake: *** [Makefile:146: all] Error 2

This error can be reproduced by changing the FROM line in the included Dockerfile to FROM ubuntu:noble and firing off a build using docker build.

Resolution

A workaround is to install and activate gcc/g++-12 toolchain as the default instead.

FROM ubuntu:noble

LABEL maintainer="dbaston@isciences.com"

RUN apt-get update && apt-get install -y \
  build-essential \
  gcc-12 \
  g++-12 \
  cmake \
  curl \
  doxygen \
  gdal-bin \
  git \
  graphviz \
  libgdal-dev \
  libgeos-dev \
  python3-dev \
  python3-pybind11 \
  python3-pytest \
  unzip \
  wget

RUN update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 10
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 10