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