isciences / exactextract

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

Build with gcc-10 error: ‘runtime_error’ is not a member of ‘std’ #20

Closed gnw3 closed 3 years ago

gnw3 commented 3 years ago

The Cmake build of exactextract_bin fails:

[ 35%] Building CXX object CMakeFiles/exactextract_bin.dir/src/gdal_dataset_wrapper.cpp.o
/opt/isciences.com/exactextractr/src/exactextract/src/gdal_dataset_wrapper.cpp: In constructor ‘exactextract::GDALDatasetWrapper::GDALDatasetWrapper(const string&, const string&, std::string)’:
/opt/isciences.com/exactextractr/src/exactextract/src/gdal_dataset_wrapper.cpp:26:24: error: ‘runtime_error’ is not a member of ‘std’
   26 |             throw std::runtime_error("Failed to open " + filename);
      |                        ^~~~~~~~~~~~~
/opt/isciences.com/exactextractr/src/exactextract/src/gdal_dataset_wrapper.cpp:39:24: error: ‘runtime_error’ is not a member of ‘std’
   39 |             throw std::runtime_error("No layer " + layer + " found in " + filename);
      |                        ^~~~~~~~~~~~~
/opt/isciences.com/exactextractr/src/exactextract/src/gdal_dataset_wrapper.cpp:49:24: error: ‘runtime_error’ is not a member of ‘std’
   49 |             throw std::runtime_error("ID field '" + m_id_field + "' not found in " + filename + ".");
      |                        ^~~~~~~~~~~~~
/opt/isciences.com/exactextractr/src/exactextract/src/gdal_dataset_wrapper.cpp: In member function ‘void exactextract::GDALDatasetWrapper::copy_field(const string&, OGRLayerH) const’:
/opt/isciences.com/exactextractr/src/exactextract/src/gdal_dataset_wrapper.cpp:82:24: error: ‘runtime_error’ is not a member of ‘std’
   82 |             throw std::runtime_error("Cannot find field " + name);
      |                        ^~~~~~~~~~~~~
make[2]: *** [CMakeFiles/exactextract_bin.dir/build.make:108: CMakeFiles/exactextract_bin.dir/src/gdal_dataset_wrapper.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:103: CMakeFiles/exactextract_bin.dir/all] Error 2

Quoting Porting to GCC 10

Previously components such as std::runtime_error, std::string and std::allocator were implicitly defined after including unrelated headers such as <array> and <optional>. Correct code should include the appropriate headers for the classes being used.

dbaston commented 3 years ago

Thanks for reporting!