我是靠谱客的博主 干净黑裤,这篇文章主要介绍Ubuntu MRPT enable_if_t error,现在分享给大家,希望可以做个参考。

参考官网安装教程,(sudo 安装,教程在这里)。安装好MRPT后,写了一个测试程序,报错如下

/usr/include/mrpt/base/include/mrpt/utils/CConfigFileBase.h:79: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type
typename = std::enable_if_t


发现 enable_if_t 是cpp14里的功能,cpp11只有enable_if。
这里写图片描述
所以改CMakeLists里面cpp版本选择

set( CMAKE_CXX_FLAGS “-std=c++11”)
改为
set( CMAKE_CXX_FLAGS “-std=c++14”)

编译成功。

CMakeLists.txt

复制代码
1
2
3
4
5
6
cmake_minimum_required( VERSION 2.8 ) project ( MRPT_example ) set( CMAKE_CXX_FLAGS "-std=c++14") FIND_PACKAGE( MRPT REQUIRED base gui) # WARNING: Add all the MRPT libs used by your program: "gui", "obs", "slam",etc. ADD_EXECUTABLE( example1 test.cpp ) TARGET_LINK_LIBRARIES(example1 ${MRPT_LIBS})

test.cpp

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* ************************************** * mrpt使用 * * ***************************************/ #include <iostream> //#include <type_traits> #include <mrpt/gui/CDisplayWindowPlots.h> using namespace std; int main(int argc, char** argv) { mrpt::gui::CDisplayWindowPlots win("path2D",400,400); win.hold_on(); win.setPos(1300,0); std::vector<double> x,y; for (int i = 0; i < 1000; i++) { double tempx = 10.0*i-500; double tempy = 9*i-500; x.push_back(tempx); y.push_back(tempy); } win.plot(x,y,"r.3"); win.axis_fit(); win.axis_equal(true); while(1); return 0; }

效果图
效果图

最后

以上就是干净黑裤最近收集整理的关于Ubuntu MRPT enable_if_t error的全部内容,更多相关Ubuntu内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(93)

评论列表共有 0 条评论

立即
投稿
返回
顶部