ROS问题:#error This file requires compiler and library support for the ISO C++ 2011 standard.

佐手、 提交于 2019-12-09 21:57:39

        在解决了上面这篇博客ROS问题:Could not find a package configuration file provided by ......的问题之后,进行编译,结果出现了如下问题:

 

 即:


    In file included from /usr/include/c++/5/type_traits:35:0,
                 from /usr/include/gtest/gtest.h:59,
                 from /home/zydz/catkin_ws/src/navigation-melodic-devel/map_server/test/rtest.cpp:32:    
    /usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
     #error This file requires compiler and library support \
      ^


分析:从所报的错误来看,是和map_server这个ROS包报的错误有关,从提示可知编译器要支持2011标准才可以,需要从编译器那里加上-std=c++11 or -std=gnu++11。因此就有了以下解决方案:

解决方案1:找到map_server这个ROS包里面的CMakeLists.txt文件,向其中添加如下代码:

SET(CMAKE_CXX_FLAGS "-std=c++0x")

解决方案2:

SET(CMAKE_CXX_FLAGS "-std=c++11 -O3")

解决方案3:

SET(CMAKE_CXX_FLAGS "-std=gnu++11")

解决方案4

add_compile_options(-std=c++11)

解决方案5

add_compile_options(-std=gnu++11)

        从以上方案任选一种,均能解决前面编译出现的报错。问题解决。

参考网址

Regex in C++: Requires compiler support error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!