Solvedoctomap Error compiling OctoMap with existing ROS-provided version

tried to install octomap:

git clone https://github.com/OctoMap/octomap.git
cd octomap/ && mkdir build && cd build/
cmake ..
make

after calling make the compilation fails upon

[ 91%] Building CXX object octovis/CMakeFiles/octovis.dir/qrc_icons.cxx.o
[ 92%] Linking CXX executable ../../bin/octovis
CMakeFiles/octovis.dir/src/ViewerGui.cpp.o: In function `octomap::OcTreeBaseImpl<octomap::ColorOcTreeNode, octomap::AbstractOccupancyOcTree>::writeData(std::ostream&) const':
ViewerGui.cpp:(.text._ZNK7octomap14OcTreeBaseImplINS_15ColorOcTreeNodeENS_23AbstractOccupancyOcTreeEE9writeDataERSo[_ZNK7octomap14OcTreeBaseImplINS_15ColorOcTreeNodeENS_23AbstractOccupancyOcTreeEE9writeDataERSo]+0xe): undefined reference to `octomap::ColorOcTreeNode::writeValue(std::ostream&) const'

[...]

ViewerGui.cpp:(.text._ZN7octomap14OcTreeBaseImplINS_15ColorOcTreeNodeENS_23AbstractOccupancyOcTreeEE8readDataERSi[_ZN7octomap14OcTreeBaseImplINS_15ColorOcTreeNodeENS_23AbstractOccupancyOcTreeEE8readDataERSi]+0x1b2): undefined reference to `octomap::ColorOcTreeNode::readValue(std::istream&)'
collect2: error: ld returned 1 exit status
make[2]: *** [../bin/octovis] Error 1
make[1]: *** [octovis/CMakeFiles/octovis.dir/all] Error 2
make: *** [all] Error 2

any idea how to fix this?

18 Answers

✔️Accepted Answer

well, I just tried to use sudo commond to build the project and succeeded.

mkdir build && cd build
sudo cmake ..
make

But I still do not know why =.=

Other Answers:

I just solved this problem by this way:
fist check ros-indigo's octomap package in :/opt/ros/indigo/share/octomap/octomap-config-version.cmake,it's version is 1.6.9; then choose to git clone https://github.com/OctoMap/octomap/tree/v1.6-fixes; finally cmake &make.

Related Issues:

7
octomap Error compiling OctoMap with existing ROS-provided version
well I just tried to use sudo commond to build the project and succeeded But I still do not know why...