OctoMap / octomap

An Efficient Probabilistic 3D Mapping Framework Based on Octrees. Contains the main OctoMap library, the viewer octovis, and dynamicEDT3D.
http://octomap.github.io
1.93k stars 657 forks source link

octomap compilation fails with gcc < 6 since 1.9.6 #319

Open SpaceIm opened 3 years ago

SpaceIm commented 3 years ago

I tried to add 1.9.6 in conan public remote (which already has 1.9.3 and 1.9.5), but compilation of octomap fails with gcc < 6

https://github.com/conan-io/conan-center-index/pull/4370#issuecomment-767710961

Click to expand log ``` ----Running------ > cd '/home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337' && cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="Release" -DCONAN_IN_LOCAL_CACHE="ON" -DCONAN_COMPILER="gcc" -DCONAN_COMPILER_VERSION="4.9" -DCONAN_CXX_FLAGS="-m64" -DCONAN_SHARED_LINKER_FLAGS="-m64" -DCONAN_C_FLAGS="-m64" -DCONAN_LIBCXX="libstdc++" -DBUILD_SHARED_LIBS="OFF" -DCMAKE_INSTALL_PREFIX="/home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/package/a506942c4fdc4003ced5ed2afee2a0486db24337" -DCMAKE_INSTALL_BINDIR="bin" -DCMAKE_INSTALL_SBINDIR="bin" -DCMAKE_INSTALL_LIBEXECDIR="bin" -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_INCLUDEDIR="include" -DCMAKE_INSTALL_OLDINCLUDEDIR="include" -DCMAKE_INSTALL_DATAROOTDIR="share" -DCONAN_CMAKE_POSITION_INDEPENDENT_CODE="ON" -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -DOCTOMAP_OMP="False" -DBUILD_TESTING="False" -Wno-dev '/home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337' ----------------- -- The C compiler identification is GNU 4.9.4 -- The CXX compiler identification is GNU 4.9.4 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/gcc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/g++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Conan: called by CMake conan helper -- Conan: called inside local cache -- Conan: Adjusting output directories -- Conan: Using cmake global configuration -- Conan: Adjusting default RPATHs Conan policies -- Conan: Adjusting language standard -- Conan: Adjusting fPIC flag (ON) -- Conan: Checking correct version: 4.9 -- Conan: C++ stdlib: libstdc++ -- octomap building as Release -- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) -- Compile octomap using: make -- Install octomap using: make install -- (be sure to set the correct CMAKE_INSTALL_PREFIX before) -- Compile API-documentation using: make docs -- Configuring done -- Generating done -- Build files have been written to: /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337 ----Running------ > cmake --build '/home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337' '--' '-j3' ----------------- Scanning dependencies of target octomath-static [ 7%] Building CXX object source_subfolder/octomap/src/math/CMakeFiles/octomath-static.dir/Vector3.cpp.o [ 14%] Building CXX object source_subfolder/octomap/src/math/CMakeFiles/octomath-static.dir/Quaternion.cpp.o [ 21%] Building CXX object source_subfolder/octomap/src/math/CMakeFiles/octomath-static.dir/Pose6D.cpp.o [ 28%] Linking CXX static library ../../../../lib/liboctomath.a [ 28%] Built target octomath-static Scanning dependencies of target octomap-static [ 35%] Building CXX object source_subfolder/octomap/src/CMakeFiles/octomap-static.dir/AbstractOcTree.cpp.o [ 50%] Building CXX object source_subfolder/octomap/src/CMakeFiles/octomap-static.dir/AbstractOccupancyOcTree.cpp.o [ 50%] Building CXX object source_subfolder/octomap/src/CMakeFiles/octomap-static.dir/Pointcloud.cpp.o In file included from /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/OcTreeNode.h:37:0, from /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/AbstractOccupancyOcTree.h:39, from /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/src/AbstractOccupancyOcTree.cpp:35: /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/octomap_types.h:69:27: error: anonymous variadic macros were introduced in C99 [-Werror=variadic-macros] #define OCTOMAP_DEBUG(...) (void)0 ^ /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/octomap_types.h:70:31: error: anonymous variadic macros were introduced in C99 [-Werror=variadic-macros] #define OCTOMAP_DEBUG_STR(...) (void)0 ^ /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/octomap_types.h:76:27: error: anonymous variadic macros were introduced in C99 [-Werror=variadic-macros] #define OCTOMAP_WARNING(...) fprintf(stderr, "WARNING: "), fprintf(stderr, __VA_ARGS__), fflush(stderr) ^ /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/octomap_types.h:78:25: error: anonymous variadic macros were introduced in C99 [-Werror=variadic-macros] #define OCTOMAP_ERROR(...) fprintf(stderr, "ERROR: "), fprintf(stderr, __VA_ARGS__), fflush(stderr) ^ In file included from /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/OccupancyOcTreeBase.h:42:0, from /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/OcTree.h:38, from /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/src/AbstractOcTree.cpp:36: /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/octomap_types.h:69:27: error: anonymous variadic macros were introduced in C99 [-Werror=variadic-macros] #define OCTOMAP_DEBUG(...) (void)0 ^ /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/octomap_types.h:70:31: error: anonymous variadic macros were introduced in C99 [-Werror=variadic-macros] #define OCTOMAP_DEBUG_STR(...) (void)0 ^ /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/octomap_types.h:76:27: error: anonymous variadic macros were introduced in C99 [-Werror=variadic-macros] #define OCTOMAP_WARNING(...) fprintf(stderr, "WARNING: "), fprintf(stderr, __VA_ARGS__), fflush(stderr) ^ /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/octomap_types.h:78:25: error: anonymous variadic macros were introduced in C99 [-Werror=variadic-macros] #define OCTOMAP_ERROR(...) fprintf(stderr, "ERROR: "), fprintf(stderr, __VA_ARGS__), fflush(stderr) ^ In file included from /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/Pointcloud.h:39:0, from /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/src/Pointcloud.cpp:52: /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/octomap_types.h:69:27: error: anonymous variadic macros were introduced in C99 [-Werror=variadic-macros] #define OCTOMAP_DEBUG(...) (void)0 ^ /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/octomap_types.h:70:31: error: anonymous variadic macros were introduced in C99 [-Werror=variadic-macros] #define OCTOMAP_DEBUG_STR(...) (void)0 ^ /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/octomap_types.h:76:27: error: anonymous variadic macros were introduced in C99 [-Werror=variadic-macros] #define OCTOMAP_WARNING(...) fprintf(stderr, "WARNING: "), fprintf(stderr, __VA_ARGS__), fflush(stderr) ^ /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/octomap_types.h:78:25: error: anonymous variadic macros were introduced in C99 [-Werror=variadic-macros] #define OCTOMAP_ERROR(...) fprintf(stderr, "ERROR: "), fprintf(stderr, __VA_ARGS__), fflush(stderr) ^ In file included from /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/OcTreeNode.h:37:0, from /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/AbstractOccupancyOcTree.h:39, from /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/src/AbstractOccupancyOcTree.cpp:35: /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/src/AbstractOccupancyOcTree.cpp: In member function 'bool octomap::AbstractOccupancyOcTree::readBinary(std::istream&)': /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/octomap_types.h:78:92: error: ISO C++98 does not support the 'z' gnu_printf length modifier [-Werror=format=] #define OCTOMAP_ERROR(...) fprintf(stderr, "ERROR: "), fprintf(stderr, __VA_ARGS__), fflush(stderr) ^ /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/src/AbstractOccupancyOcTree.cpp:173:7: note: in expansion of macro 'OCTOMAP_ERROR' OCTOMAP_ERROR("Tree size mismatch: # read nodes (%zu) != # expected nodes (%d)\n",this->size(), size); ^ In file included from /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/OccupancyOcTreeBase.h:44:0, from /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/OcTree.h:38, from /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/src/AbstractOcTree.cpp:36: /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/OcTreeBaseImpl.h:251:19: error: ISO C++ 1998 does not support 'long long' [-Werror=long-long] unsigned long long memoryFullGrid() const; ^ cc1plus: all warnings being treated as errors make[2]: *** [source_subfolder/octomap/src/CMakeFiles/octomap-static.dir/AbstractOccupancyOcTree.cpp.o] Error 1 make[2]: *** Waiting for unfinished jobs.... In file included from /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/OcTreeBaseImpl.h:573:0, from /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/OccupancyOcTreeBase.h:44, from /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/OcTree.h:38, from /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/src/AbstractOcTree.cpp:36: /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/OcTreeBaseImpl.hxx: In member function 'std::istream& octomap::OcTreeBaseImpl::readNodesRecurs(NODE*, std::istream&)': /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/OcTreeBaseImpl.hxx:830:45: error: ISO C++ 1998 does not support 'long long' [-Werror=long-long] std::bitset<8> children ((unsigned long long) children_char); ^ /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/OcTreeBaseImpl.hxx: At global scope: /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/OcTreeBaseImpl.hxx:850:17: error: ISO C++ 1998 does not support 'long long' [-Werror=long-long] unsigned long long OcTreeBaseImpl::memoryFullGrid() const{ ^ /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/OcTreeBaseImpl.hxx: In member function 'long long unsigned int octomap::OcTreeBaseImpl::memoryFullGrid() const': /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/OcTreeBaseImpl.hxx:862:27: error: ISO C++ 1998 does not support 'long long' [-Werror=long-long] return (unsigned long long)((size_x/resolution) * (size_y/resolution) * (size_z/resolution) ^ In file included from /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/OccupancyOcTreeBase.h:506:0, from /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/OcTree.h:38, from /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/src/AbstractOcTree.cpp:36: /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/OccupancyOcTreeBase.hxx: In member function 'std::istream& octomap::OccupancyOcTreeBase::readBinaryNode(std::istream&, NODE*)': /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/OccupancyOcTreeBase.hxx:963:46: error: ISO C++ 1998 does not support 'long long' [-Werror=long-long] std::bitset<8> child1to4 ((unsigned long long) child1to4_char); ^ /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337/source_subfolder/octomap/include/octomap/OccupancyOcTreeBase.hxx:964:46: error: ISO C++ 1998 does not support 'long long' [-Werror=long-long] std::bitset<8> child5to8 ((unsigned long long) child5to8_char); ^ cc1plus: all warnings being treated as errors make[2]: *** [source_subfolder/octomap/src/CMakeFiles/octomap-static.dir/Pointcloud.cpp.o] Error 1 cc1plus: all warnings being treated as errors make[2]: *** [source_subfolder/octomap/src/CMakeFiles/octomap-static.dir/AbstractOcTree.cpp.o] Error 1 make[1]: *** [source_subfolder/octomap/src/CMakeFiles/octomap-static.dir/all] Error 2 make: *** [all] Error 2 octomap/1.9.6: WARN: Build folder is dirty, removing it: /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337 octomap/1.9.6: ERROR: Package 'a506942c4fdc4003ced5ed2afee2a0486db24337' build failed octomap/1.9.6: WARN: Build folder /home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337 ERROR: octomap/1.9.6: Error in build() method, line 48 cmake.build() ConanException: Error 2 while executing cmake --build '/home/conan/w/cci_PR-4370/.conan/data/octomap/1.9.6/_/_/build/a506942c4fdc4003ced5ed2afee2a0486db24337' '--' '-j3' ```
SpaceIm commented 3 years ago

Ok, I see that -Wno-error has been replaced by -Werror: https://github.com/OctoMap/octomap/commit/85bbd66360290461a9a80927761bf197f6511f6a#diff-c2c2bf6142b175565390edaed1190aa0f8cf0f167ed78106a2f12996420357bc

While it's recommended for developers, it would be nice to allow to disable those developer compilation flags for package managers (through an option). It can break with any new compiler version.

ahornung commented 3 years ago

While it's recommended for developers, it would be nice to allow to disable those developer compilation flags for package managers (through an option). It can break with any new compiler version.

Good point, this was introduced in https://github.com/OctoMap/octomap/pull/312

Are there best practices for an option through CMake? Otherwise I tend to revert the corresponding change.

SpaceIm commented 3 years ago

I guess you can add an option like OCTOMAP_DEVELOPER_FLAGS, it's fine. Then depending on its value, Werror is injected or not.

marcelino-pensa commented 3 years ago

It would also be great to allow us to choose our compiler. I came across this issue because my compiler is using c++98 by default, but I could compile with -Werror by changing the compiler to c++11 (i.e., add the following to /octomap/CMakeLists.txt):

add_compile_options(-std=c++11)

It doesn't solve both my problem and Spacelm's problem, as it seems that Spacelm needs to compile with gcc 6.

ahornung commented 3 years ago

It would also be great to allow us to choose our compiler. I came across this issue because my compiler is using c++98 by default, but I could compile with -Werror by changing the compiler to c++11

Just to be sure, you probably mean compiler options / standard, and not the actual compiler, don't you?

You can use the standard CMake options for that but will have to disable the octovis Qt5 option, because that one will set the C++ Version to C++11 E.g.

cmake .. -DCMAKE_CXX_STANDARD=20 -DOCTOVIS_QT5=Off

or cmake .. -DCMAKE_CXX_STANDARD=11

should both work.

@SpaceIm: Did I understand you correctly that removing -Werror fixes this issue for you?