Я работаю над групповым проектом с ROS и C ++ в Ubuntu 16.04. Все работает нормально, пока две недели назад я не получил эту ошибку
сообщение неожиданно:
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 сообщение об ошибке строки .
Теперь я думаю, что может быть небольшая проблема с cstring, но я, к сожалению, понятия не имею, как ее решить.
Мой поиск в Google предполагает, что 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 ++?
Я довольно близок к настройке системы
с нуля, так что вы, ребята, моя последняя надежда.