编译ORB_SLAM2之前要先安装Pangolin不然会报错
Pangolin的安装
1.下载pangolin
git clone https://github.com/stevenlovegrove/Pangolin.git
2.安装依赖
sudo apt install libglew-dev
sudo apt install cmake
sudo apt install libgl1-mesa-dev
sudo apt install libpython2.7-dev
sudo apt install pkg-config
3.安装pangolin
cd Pangolin
mkdir build
cd build
cmake ..
cmake --build . # 注意最后那个点
测试安装是否成功
利用example里面的例子测试
cd /Pangolin/examples/HelloPangolin
mkdir build
cd build
cmake ..
make -j4
./HelloPangolin
显示可拖拽的彩色立体方块即安装成功。
编译ORB_SLAM2的Pangolin错误
/home/river/soft/Pangolin/components/pango_core/include/sigslot/signal.hpp:269:26: error: ‘decay_t’ is not a member of ‘std’; did you mean ‘decay’?
269 | function_traits<std::decay_t<T>>::ptr(t, d);
这个错误是由Pangolin引起的,将ORB-SLAM2最外层的CMakeLists.txt中的c++支持从c++11修改为c++14即可。
原来的
# Check C++11 or C++0x support
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
add_definitions(-DCOMPILEDWITHC11)
message(STATUS "Using flag -std=c++11.")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
add_definitions(-DCOMPILEDWITHC0X)
message(STATUS "Using flag -std=c++0x.")
else()
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
修改后的
# Check C++14 or C++0x support
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX14)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
add_definitions(-DCOMPILEDWITHC11)
message(STATUS "Using flag -std=c++14.")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
add_definitions(-DCOMPILEDWITHC0X)
message(STATUS "Using flag -std=c++0x.")
else()
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++14 support. Please use a different C++ compiler.")
endif()
再编译就能通过了。