cartographer安装步骤简述 cartographer_ros 编译问题解决

cartographer安装步骤如下,如没有其他问题的话一般都是可以过的。

# Install the required libraries that are available as debs.
sudo apt-get update
sudo apt-get install -y \
    cmake \
    g++ \
    git \
    google-mock \
    libboost-all-dev \
    libcairo2-dev \
    libeigen3-dev \
    libgflags-dev \
    libgoogle-glog-dev \
    liblua5.2-dev \
    libsuitesparse-dev \
    ninja-build \
    python-sphinx
VERSION="1.13.0"

# Build and install Ceres.
git clone https://ceres-solver.googlesource.com/ceres-solver
cd ceres-solver
git checkout tags/${VERSION}
mkdir build
cd build
cmake .. -G Ninja -DCXX11=ON
ninja
CTEST_OUTPUT_ON_FAILURE=1 ninja test
sudo ninja install
VERSION="v3.4.1"

# Build and install proto3.
git clone https://github.com/google/protobuf.git
cd protobuf
git checkout tags/${VERSION}
mkdir build
cd build
cmake -G Ninja \
  -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
  -DCMAKE_BUILD_TYPE=Release \
  -Dprotobuf_BUILD_TESTS=OFF \
  ../cmake
ninja
sudo ninja install
# Build and install Cartographer.
cd cartographer
mkdir build
cd build
cmake .. -G Ninja
ninja
CTEST_OUTPUT_ON_FAILURE=1 ninja test
sudo ninja install

在安装完成之后,安装cartographer_ros 我遇到了下面的问题:

relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libgflags.a: error adding symbols: Bad value

遇到之后,发现谷歌网上一大堆天花乱坠的方法,愣是没一篇文章说明到底怎么搞,幸好运气好被我发现了。
这个问题的起因就是因为gflags没有按照共享lib的方式来编译,因此需要先卸载掉再重新装(也可以不卸载直接装)。
找到下载好的gflags,然后输入下面指令,再重新编译,问题就解决了。

cd gflags/build
cmake .. -DBUILD_SHARED_LIBS=ON
make -j2
sudo make -j2 install

你可能感兴趣的:(ros,SLAM)