cstring incompability when include <ros/ros.h>
Out of nowhere my ros kinetic project fails building with the stacktrace below. Coulnd't figure out what the problem is, so i reinstalled my whole ros project. But the error is still the same. Seems as there is some kind of version incompability below in the stacktrace. Iam pretty new to c++ and have no clue what the problem is. Googled a lot yesterday but coulnd't find any help. What could i do to isolate the error and find the possible incompatibility?
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/DLR/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/DLR/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/DLR/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));
EDIT: as asked I post the code and the cmakelist
hello_world.cpp:
#include <ros/ros.h>
int main(int argc, char** argv)
{
ROS_INFO_STREAM("Welcome to the tutorials! You have successfully "
"completed the installation.");
return 0;
}
CMakeList:
cmake_minimum_required(VERSION 2.8.3)
project(hello_world)
add_compile_options(-std=c++14)
find_package(catkin_simple REQUIRED)
catkin_simple()
cs_add_executable(hello_world src/hello_world.cpp)
cs_install()
cs_export()
Have you upgraded compilers by any chance? Does a simple test program still compile? Something like:
Can you show us your code? even cmakelists.txt just in case
@Solrac3589, the unqualified use of
cout
appears to occur in a system header (ie:/usr/include/string.h
), not in code by @belorenz.@gvdhoorn yes, i just saw and edited my comment.
Added the code and the cmakelist. @gvdhoorn i was able compile your example without any problems. With
include <ros/ros.h>
on the other hand it fails like the stacktrace above.If you remove
-std=c++14
, does it still fail?Yes, it still fails.
Could isolate the problem to
<cstring>
. This fails with the same error message. I am fairly new to ros and to c++. What can I do to 'replace' cstring with a working one?