我正在Ubuntu 16.04上使用ROS和C ++进行小组项目。一切正常,直到两周前我收到此错误 消息突如其来:
In file included from /usr/include/c++/5/cstring:42:0,
from /usr/include/boost/math/special_functions/detail/fp_traits.hpp:23,
from /usr/include/boost/math/special_functions/fpclassify.hpp:20,
from /usr/include/boost/math/special_functions/round.hpp:16,
from /opt/ros/kinetic/include/ros/time.h:58,
from /opt/ros/kinetic/include/ros/ros.h:38,
from /home/benjamin/Documents/bob_ws/src/tutorial/hello_world/src/hello_world.cpp:1:
/usr/include/string.h: In function ‘size_t strlen(const char*)’:
/usr/include/string.h:395:6: error: ‘cout’ was not declared in this scope
cout << *__s;
^
/usr/include/string.h:395:6: note: suggested alternative:
In file included from /opt/ros/kinetic/include/ros/time.h:54:0,
from /opt/ros/kinetic/include/ros/ros.h:38,
from /home/benjamin/Documents/bob_ws/src/tutorial/hello_world/src/hello_world.cpp:1:
/usr/include/c++/5/iostream:61:18: note: ‘std::cout’
extern ostream cout; /// Linked to standard output
^
In file included from /usr/include/features.h:367:0,
from /usr/include/stdlib.h:24,
from /opt/ros/kinetic/include/ros/platform.h:53,
from /opt/ros/kinetic/include/ros/time.h:53,
from /opt/ros/kinetic/include/ros/ros.h:38,
from /home/benjamin/Documents/bob_ws/src/tutorial/hello_world/src/hello_world.cpp:1:
/usr/include/string.h:396:6: error: expected primary-expression before ‘)’ token
__THROW __attribute_pure__ __nonnull ((1));
作为C ++和ROS的新手,我首先想到的是,我因安装/删除了一些软件包而陷入困境。所以我尝试重新安装整个ros框架。没用,所以我写了一些程序
(我认为)表明了我的问题所在。我不能包含<cstring>
:
#include <cstring>
int main(int argc, char** argv)
{
return 0;
}
使用g++ -Wall a.cpp -o atest
进行编译时,我得到了2500 row error message。
现在,我认为cstring可能有一点问题,但是可惜我不知道如何解决它。
我的谷歌搜索表明locate cstring | grep include
可能是有趣的:
/usr/include/boost/compatibility/cpp_c_headers/cstring
/usr/include/boost/python/docstring_options.hpp
/usr/include/boost/test/utils/basic_cstring
/usr/include/boost/test/utils/basic_cstring/basic_cstring.hpp
/usr/include/boost/test/utils/basic_cstring/basic_cstring_fwd.hpp
/usr/include/boost/test/utils/basic_cstring/bcs_char_traits.hpp
/usr/include/boost/test/utils/basic_cstring/compare.hpp
/usr/include/boost/test/utils/basic_cstring/io.hpp
/usr/include/c++/4.8/cstring
/usr/include/c++/5/cstring
/usr/include/qt4/Qt/q3cstring.h
/usr/include/qt4/Qt3Support/q3cstring.h
安装两个版本的C ++可能是一个问题吗?
我即将设置系统 从头开始,所以你们是我的最后希望。
答案 0 :(得分:0)
由于@molbdnilo和@Konrad Rudolph,我发现我的ItemWriter
(是C头文件)以某种方式试图导入/usr/include/string.h
(这是c ++库)。
在工作/usr/include/c++/5/iostream
的vim差异之后,我删除了唯一的区别,只是iostream的include语句。
按照@digitalarbeiter的建议,手动更改此类文件中的某些代码通常是个坏主意,因此我重新安装了string.h
libc6-dev
它仍然有效。
我仍然不知道这怎么发生。该文件在4月进行了编辑,该错误在10月发生。无论如何,要感谢所有帮助者!