1.首先安裝Clion:
1)解壓
2)進入bin文件./clion.sh
3)使用Activation code激活
2. 安裝Eigen3
1)查看Eigen的包$ apt-cache search eigen3
2)下載Eigen$ sudo apt-get install libeigen3-dev
3)查看Eigen安裝路進,用apt裝的話就是在/usr/include的。手動編譯纔可能變掉。
$ whereis eigen3
eigen3: /usr/include/eigen3
或者使用:
$ sudo updatedb
$ locate eigen3
4) clion-CMakelists.txt中添加
include_directories(/usr/include/eigen3)
5)輸入代碼測試:
#include <iostream>
#include <Eigen/Dense>
using namespace Eigen;
using namespace std;
int main()
{
MatrixXd m = MatrixXd::Random(3,3);
m = (m + MatrixXd::Constant(3,3,1.2)) * 50;
cout << "m =" << endl << m << endl;
VectorXd v(3);
v << 1, 2, 3;
cout << "m * v =" << endl << m * v << endl;
}
3.安裝Pangolin
1) use pangolin: slambook/3rdpart/Pangolin
or download it from github: https://github.com/stevenlovegrove/Pangolin
2)安裝依賴項
install dependency for pangolin (mainly the OpenGL):
sudo apt-get install libglew-dev
3)compile and install pangolin
cd [path-to-pangolin]
mkdir build
cd build
cmake …
make
sudo make install
安裝成功。
4)clion-CMakelists.txt如下:
cmake_minimum_required(VERSION 3.10)
project(visualizeGeometry)
set(CMAKE_CXX_STANDARD 11)
添加Eigen頭文件
include_directories( "/usr/include/eigen3" )
#添加Pangolin依賴
find_package( Pangolin )
include_directories( "/usr/local/include/pangolin" )
add_executable(visualizeGeometry main.cpp)
target_link_libraries( visualizeGeometry ${Pangolin_LIBRARIES} )
4.安裝Sophus
git clone http://github.com/strasdat/Sophus.git
cd sophus
git checkout a621ff
mkdir build
cd build
cmake ..
make
5.安裝PCL
sudo add-apt-repository ppa:v-launchpad-jochen-sprickerhof-de/pcl //加入源
sudo apt-get update //更新
sudo apt-get install libpcl-dev pcl-tools
運行測試程序時出現以下錯誤:
make[2]: *** No rule to make target ‘/usr/lib/x86_64-linux-gnu/libproj.so’, needed by ‘joinMap’. Stop.
CMakeFiles/Makefile2:67: recipe for target ‘CMakeFiles/joinMap.dir/all’ failed
make[1]: *** [CMakeFiles/joinMap.dir/all] Error 2
Makefile:83: recipe for target ‘all’ failed
make: *** [all] Error 2
*** Failure: Exit code 2 ***
解決方法,執行sudo apt-get install libproj-dev
再次編譯出現以下錯誤:
– Build files have been written to: /home/wd/code/slambook-master/ch5/joinMap/build
[ 50%] Linking CXX executable joinMap
/usr/bin/ld: cannot find -lvtkproj4
collect2: error: ld returned 1 exit status
CMakeFiles/joinMap.dir/build.make:349: recipe for target ‘joinMap’ failed
make[2]: *** [joinMap] Error 1
CMakeFiles/Makefile2:67: recipe for target ‘CMakeFiles/joinMap.dir/all’ failed
make[1]: *** [CMakeFiles/joinMap.dir/all] Error 2
Makefile:83: recipe for target ‘all’ failed
make: *** [all] Error 2
*** Failure: Exit code 2 ***
解決方法:需要在cmakelist中加一條指令修復,即在add_executable語句前面加上list(REMOVE_ITEM PCL_LIBRARIES “vtkproj4”)
參考自:
https://www.cnblogs.com/sincere-diligence/p/9336045.html
https://blog.csdn.net/sgdd123/article/details/80099003
https://blog.csdn.net/danmeng8068/article/details/77341532
6.Ceres
1)首先安裝ceres的依賴庫:
sudo apt-get install liblapack-dev libsuitesparse-dev libcxsparse3.1.4 libgflags-dev libgoogle-glog-dev libgtest-dev
2)從github上下載源碼:https://github.com/ceres-solver/ceres-solver
3)編譯安裝:
cd 安裝包文件路徑
mkdir build
cd build
cmake …
make -j8
sudo make install
4)頭文件:/usr/local/include/ceres/
庫文件:/usr/local/lib/libceres.a
7.g2o
1)安裝依賴庫:
sudo apt-get install libqt4-dev qt4-qmake libqglviewer-dev
可選:
libcholmod3.0.6 qtdeclarative5-dev qt5-qmake libcxsparse3.1.4 libsuitesparse-dev
2)從github上下載源碼:https://github.com/RainerKuemmerle/g2o
3)編譯安裝:同上。
4)頭文件:/usr/local/include
庫文件:/usr/local/lib/