r-barnes / Barnes2019-DepressionHierarchy

Fast handling of depressions in flow graphs
MIT License
9 stars 7 forks source link

Syntax errors during compilation (Ubuntu 16.04) #11

Closed speleophysics closed 4 years ago

speleophysics commented 4 years ago

I attempted following the instructions in the Readme to compile dephier.exe. However, I ran into what appear to be syntax errors during compilation of dephier.hpp. I'm on Ubuntu 16.04 and, after updating for this project, have CMake 3.17.3. C and CXX compilers are GNU 5.4.0. My best guess is that it is a compiler version issue, but without recent experience in C++ I'm not sure where to start. Googling didn't immediately lead to any clues. Error message is below:

Scanning dependencies of target richdem [ 14%] Building CXX object submodules/richdem/CMakeFiles/richdem.dir/include/richdem/richdem.cpp.o [ 28%] Building CXX object submodules/richdem/CMakeFiles/richdem.dir/include/richdem/common/random.cpp.o [ 42%] Linking CXX static library librichdem.a [ 42%] Built target richdem Scanning dependencies of target dephier.exe Scanning dependencies of target dephier_paper_tests.exe [ 57%] Building CXX object CMakeFiles/dephier.exe.dir/src/main.cpp.o [ 71%] Building CXX object CMakeFiles/dephier_paper_tests.exe.dir/src/dephier_paper_tests.cpp.o In file included from /home/mcoving/github/Barnes2019-DepressionHierarchy/src/main.cpp:1:0: /home/mcoving/github/Barnes2019-DepressionHierarchy/include/dephier/dephier.hpp:24:18: error: expected ‘{’ before ‘::’ token namespace richdem::dephier { ^ /home/mcoving/github/Barnes2019-DepressionHierarchy/include/dephier/dephier.hpp:24:20: error: ‘dephier’ in namespace ‘::’ does not name a type namespace richdem::dephier { ^ In file included from /home/mcoving/github/Barnes2019-DepressionHierarchy/src/main.cpp:1:0: /home/mcoving/github/Barnes2019-DepressionHierarchy/include/dephier/dephier.hpp:268:64: error: expected ‘}’ before end of line /home/mcoving/github/Barnes2019-DepressionHierarchy/include/dephier/dephier.hpp:268:64: error: expected declaration before end of line In file included from /home/mcoving/github/Barnes2019-DepressionHierarchy/src/dephier_paper_tests.cpp:1:0: /home/mcoving/github/Barnes2019-DepressionHierarchy/include/dephier/dephier.hpp:24:18: error: expected ‘{’ before ‘::’ token namespace richdem::dephier { ^ /home/mcoving/github/Barnes2019-DepressionHierarchy/include/dephier/dephier.hpp:24:20: error: ‘dephier’ in namespace ‘::’ does not name a type namespace richdem::dephier { ^ In file included from /home/mcoving/github/Barnes2019-DepressionHierarchy/src/dephier_paper_tests.cpp:1:0: /home/mcoving/github/Barnes2019-DepressionHierarchy/include/dephier/dephier.hpp:268:64: error: expected ‘}’ before end of line /home/mcoving/github/Barnes2019-DepressionHierarchy/include/dephier/dephier.hpp:268:64: error: expected declaration before end of line CMakeFiles/dephier.exe.dir/build.make:82: recipe for target 'CMakeFiles/dephier.exe.dir/src/main.cpp.o' failed make[2]: [CMakeFiles/dephier.exe.dir/src/main.cpp.o] Error 1 CMakeFiles/Makefile2:116: recipe for target 'CMakeFiles/dephier.exe.dir/all' failed make[1]: [CMakeFiles/dephier.exe.dir/all] Error 2 make[1]: Waiting for unfinished jobs.... CMakeFiles/dephier_paper_tests.exe.dir/build.make:82: recipe for target 'CMakeFiles/dephier_paper_tests.exe.dir/src/dephier_paper_tests.cpp.o' failed make[2]: [CMakeFiles/dephier_paper_tests.exe.dir/src/dephier_paper_tests.cpp.o] Error 1 CMakeFiles/Makefile2:143: recipe for target 'CMakeFiles/dephier_paper_tests.exe.dir/all' failed make[1]: [CMakeFiles/dephier_paper_tests.exe.dir/all] Error 2 Makefile:149: recipe for target 'all' failed make: [all] Error 2

speleophysics commented 4 years ago

Indeed. Seemed to be the old version of GNU compiler. I upgraded to GNU 9.3.0, reinstalled netcdf and gdal libraries as well as cmake. Then it compiled. Might be good to specify something about required version of the compiler in the Readme.

r-barnes commented 4 years ago

This is an issue with nested namespace definitions, which are part of C++-17 and became available in GCC6. I could denest the definitions, but there are other C++-17 features we use which I'd prefer to keep. I've modified the README file to contain a list of compilers have been reported to work and those that haven't.