一、问题描述
编译ROS程序的时候报错:
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.
具体终端报错信息
In file included from /usr/include/c++/5/random:35:0,
from /home/wang/***/src/***/include/***/positioning_system.hpp:4,
from /home/wang/***/src/***/src/sensors/positioning_system.cpp:6:
/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 \
^
In file included from /usr/include/c++/5/random:35:0,
from /home/wang/***/src/****/include/***/odometry.hpp:4,
from /home/wang/***/src/***/src/sensors/odometry.cpp:6:
/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 \
二、解决方法
这个问题一般是编译需要 C++ 11 ,但是没有在编译选项中配置 C++ 11 进行编译导致的。所以执行需要在 CMakLists.txt
中 添加如下编译选项即可:
# Compile as C++11
add_compile_options(-std=c++11)
然后再次编译,基本可以编译通过了~~~~