isciences / exactextract

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

Compilation errors on Linux #17

Closed cwoelkers closed 4 years ago

cwoelkers commented 4 years ago

Using cmake 3.17.2, gcc 5.4.0, geos 3.8.1, make 3.82. cmake works fine but when I try to run the make command the following pops up.

Scanning dependencies of target exactextract_SHARED
[  2%] Building CXX object CMakeFiles/exactextract_SHARED.dir/src/area.cpp.o
[  4%] Building CXX object CMakeFiles/exactextract_SHARED.dir/src/box.cpp.o
[  6%] Building CXX object CMakeFiles/exactextract_SHARED.dir/src/cell.cpp.o
[  8%] Building CXX object CMakeFiles/exactextract_SHARED.dir/src/coordinate.cpp.o
[ 10%] Building CXX object CMakeFiles/exactextract_SHARED.dir/src/floodfill.cpp.o
In file included from /root/exactextract/src/floodfill.cpp:16:0:
/root/exactextract/src/grid.h: In constructor ‘exactextract::Grid<extent_tag>::Grid(const exactextract::Box&, double, double)’:
/root/exactextract/src/grid.h:40:56: error: declaration of ‘dy’ shadows a member of 'this' [-Werror=shadow]
         Grid(const Box & extent, double dx, double dy) :
                                                        ^
/root/exactextract/src/grid.h:40:56: error: declaration of ‘dx’ shadows a member of 'this' [-Werror=shadow]
/root/exactextract/src/grid.h:40:56: error: declaration of ‘extent’ shadows a member of 'this' [-Werror=shadow]
In file included from /root/exactextract/src/floodfill.cpp:16:0:
/root/exactextract/src/grid.h: In function ‘exactextract::Grid<exactextract::bounded_extent> exactextract::common_grid(T, T)’:
/root/exactextract/src/grid.h:342:26: error: parameter declared ‘auto’
                 [](auto& acc, auto& op) {
                          ^
/root/exactextract/src/grid.h:342:37: error: parameter declared ‘auto’
                 [](auto& acc, auto& op) {
                                     ^
/root/exactextract/src/grid.h: In lambda function:
/root/exactextract/src/grid.h:343:28: error: ‘acc’ was not declared in this scope
                     return acc.common_grid(op.grid());
                            ^
/root/exactextract/src/grid.h:343:44: error: ‘op’ was not declared in this scope
                     return acc.common_grid(op.grid());
                                            ^
In file included from /root/exactextract/src/floodfill.h:23:0,
                 from /root/exactextract/src/floodfill.cpp:17:
/root/exactextract/src/matrix.h: In constructor ‘exactextract::Matrix<T>::Matrix(std::size_t, std::size_t)’:
/root/exactextract/src/matrix.h:31:42: error: declaration of ‘cols’ shadows a member of 'this' [-Werror=shadow]
         Matrix(size_t rows, size_t cols) :
                                          ^
/root/exactextract/src/matrix.h:31:42: error: declaration of ‘rows’ shadows a member of 'this' [-Werror=shadow]
/root/exactextract/src/matrix.h: In constructor ‘exactextract::Matrix<T>::Matrix(std::size_t, std::size_t, T)’:
/root/exactextract/src/matrix.h:41:51: error: declaration of ‘cols’ shadows a member of 'this' [-Werror=shadow]
         Matrix(size_t rows, size_t cols, T value) :
                                                   ^
/root/exactextract/src/matrix.h:41:51: error: declaration of ‘rows’ shadows a member of 'this' [-Werror=shadow]
/root/exactextract/src/matrix.h: In constructor ‘exactextract::Matrix<T>::Matrix(const std::vector<std::vector<_Tp> >&)’:
/root/exactextract/src/matrix.h:53:67: error: declaration of ‘data’ shadows a member of 'this' [-Werror=shadow]
         explicit Matrix(const std::vector<std::vector<T>> & data) :
                                                                   ^
/root/exactextract/src/matrix.h:60:24: error: declaration of ‘row’ shadows a member of 'this' [-Werror=shadow]
             for (auto& row : data) {
                        ^
/root/exactextract/src/matrix.h: In member function ‘T& exactextract::Matrix<T>::operator()(std::size_t, std::size_t)’:
/root/exactextract/src/matrix.h:72:47: error: declaration of ‘row’ shadows a member of 'this' [-Werror=shadow]
         T& operator()(size_t row, size_t col) {
                                               ^
/root/exactextract/src/matrix.h: In member function ‘T exactextract::Matrix<T>::operator()(std::size_t, std::size_t) const’:
/root/exactextract/src/matrix.h:77:52: error: declaration of ‘row’ shadows a member of 'this' [-Werror=shadow]
         T operator()(size_t row, size_t col) const {
                                                    ^
/root/exactextract/src/matrix.h: In member function ‘void exactextract::Matrix<T>::increment(std::size_t, std::size_t, const T&)’:
/root/exactextract/src/matrix.h:93:63: error: declaration of ‘row’ shadows a member of 'this' [-Werror=shadow]
         void increment(size_t row, size_t col, const T & val) {
                                                               ^
/root/exactextract/src/matrix.h: In member function ‘T* exactextract::Matrix<T>::row(std::size_t)’:
/root/exactextract/src/matrix.h:101:28: error: declaration of ‘row’ shadows a member of 'this' [-Werror=shadow]
         T* row(size_t row) {
                            ^
cc1plus: all warnings being treated as errors
make[2]: *** [CMakeFiles/exactextract_SHARED.dir/src/floodfill.cpp.o] Error 1
make[1]: *** [CMakeFiles/exactextract_SHARED.dir/all] Error 2
make: *** [all] Error 2
dbaston commented 4 years ago

Does git rev-parse HEAD show 73cc0f633c8ce35a08211927faf1d18c06028f9c ?

cwoelkers commented 4 years ago

Yes it does.

dbaston commented 4 years ago

I'm not sure how to explain what you're seeing. I downloaded gcc 5.4.0 and compiled it with no warnings or errors. And the error that's causing compilation to fail: /root/exactextract/src/grid.h:342:37: error: parameter declared ‘auto’ [](auto& acc, auto& op) {

implies compilation under C++11, not C++14.

cwoelkers commented 4 years ago

According to the table at https://gcc.gnu.org/projects/cxx-status.html under C++14 GCC 5 and above supports it. GCC 6 and above has it set to automatically compile under C++14 but the command line flag -std=c++14 needs to be given if using GCC 5. Perhaps a change to the cmake script to detect this and add the flag for future proofing?

dbaston commented 4 years ago

The flag should be set by this, though: https://github.com/isciences/exactextract/blob/master/CMakeLists.txt#L8

I think you can do make VERBOSE=1 to see what flags are actually being sent to the compiler.

cwoelkers commented 4 years ago

The VERBOSE showed the command and a bigger issue. CMAKE was using /bin/gcc as it's compiler which is not where my GCC 5.4 compiler is located. The PATH is set correctly so BASH will find the right location, a "which gcc" gives it perfectly, but cmake seems to not be following the PATH order. I was able to fix this by declaring the CMAKE_C_COMPILER and CMAKE_CXX_COMPILER variables in the cmake command. This got things a lot farther but now I get the following:


[ 86%] Building CXX object CMakeFiles/exactextract_bin.dir/src/exactextract.cpp.o
/cm/shared/apps/gcc5/5.4.0/bin/g++  -DGEOS_USE_ONLY_R_API -I/root/exactextract/cmake-build-release/generated -I/root/exactextract/src -I/usr/include/gdal -isystem /root/exactextract/cmake-build-release/CLI11  -Werror -Wall -Wextra -Wshadow -std=c++14 -o CMakeFiles/exactextract_bin.dir/src/exactextract.cpp.o -c /root/exactextract/src/exactextract.cpp
In file included from /root/exactextract/src/exactextract.cpp:22:0:
/root/exactextract/src/gdal_dataset_wrapper.h:35:57: error: ‘OGRLayerH’ has not been declared
         void copy_field(const std::string & field_name, OGRLayerH to) const;
                                                         ^
/root/exactextract/src/gdal_dataset_wrapper.h:41:9: error: ‘OGRFeatureH’ does not name a type
         OGRFeatureH m_feature;
         ^
/root/exactextract/src/gdal_dataset_wrapper.h:42:9: error: ‘OGRLayerH’ does not name a type
         OGRLayerH m_layer;
         ^
make[2]: *** [CMakeFiles/exactextract_bin.dir/src/exactextract.cpp.o] Error 1
make[2]: Leaving directory `/root/exactextract/cmake-build-release'
make[1]: *** [CMakeFiles/exactextract_bin.dir/all] Error 2
make[1]: Leaving directory `/root/exactextract/cmake-build-release'
make: *** [all] Error 2
dbaston commented 4 years ago

Are you using GDAL 1.x ?

cwoelkers commented 4 years ago

1.11.4 Does it need to be a higher version?

dbaston commented 4 years ago

I'm not sure the minimum version, but it's at least 2.0.

cwoelkers commented 4 years ago

That makes sense. I'm working on compiling GDAL 3, and it requirements, right now so after all that is done I'm hoping it works. Although I don't code I do a lot of sys admin stuff. I would suggest lisiting the requirements in the README doc to keep more folks from bombarding you with questions. So far we know it requires GCC 5.x, GDAL 2.x(or 3.x) and CMAKE 3.x.