ros-drivers/rosserial

cstring: No such file or directory

Opened this issue ยท 17 comments

Hello
I'm using Arduino IDE 1.8.13 and Arduino Uno
When I try to verify/compile the HelloWorld example I'm getting this error in the IDE:

In file included from /home/user/Arduino/libraries/ros_lib/std_msgs/Time.h:7:0,
                 from /home/user/Arduino/libraries/ros_lib/ros/node_handle.h:40,
                 from /home/user/Arduino/libraries/ros_lib/ros.h:38,
                 from /home/user/Arduino/libraries/ros_lib/examples/HelloWorld/HelloWorld.pde:6:
/home/user/Arduino/libraries/ros_lib/ros/msg.h:40:10: fatal error: cstring: No such file or directory
 #include <cstring>
          ^~~~~~~~~
compilation terminated.
exit status 1
Error compiling for board Arduino Uno.

I have exactly the same problem! Exactly!
Arduino IDE 1.8.14, Ubuntu 20.04 LTS, ROS Noetic.
Installing rosserial-arduino using binaries just began to work a few days ago (as described in 2.1.1):
http://wiki.ros.org/rosserial_arduino/Tutorials/Arduino%20IDE%20Setup
Seems like it at least, no errors. And now this, it's so frustrating...
Any advice much appreciated!
Would it help to post the verbose compilation output message from Arduino IDE? It contains a lot...

Hi
Still didn't find any solution for that

Me too, waiting if there will be somebody to solve this.
In file included from /home/fc/Arduino/libraries/ros_lib/std_msgs/Time.h:7:0,
from /home/fc/Arduino/libraries/ros_lib/ros/node_handle.h:40,
from /home/fc/Arduino/libraries/ros_lib/ros.h:38,
from /home/fc/catkin_ws/src/common_canonical/led_strip_control/firmware/ledstrip_ros/ledstrip_ros.ino:2:
/home/fc/Arduino/libraries/ros_lib/ros/msg.h:40:10: fatal error: cstring: No such file or directory
#include
^~~~~~~~~
compilation terminated.

the same problem

Hi
I have the same issue

Maybe this can help a bit.

Remove folder ros_lib inside libraries directory.
Then got to Arduino IDE->Sketch->Include Library->Manage Libraries... ( Ctrl+Shift+I )
And search for "rosserial" and install: Rosserial Arduino Library by Michael Ferguson

Using version 0.7.9, worked with fresh new Arduino Uno and Arduino Mega. Also able to compile for Seeeduino Zero (integrated on Odyssey X86J4105)

The #525 works well for me finally .... It's very helpful !

Both the above tips worked for me, when using the Arduino IDE.
Modifying the msg.h as described helped, and also gave a working ros_lib in Arduino IDE.
However, when using CMake with rosserial_arduino as described here:
http://wiki.ros.org/rosserial_arduino/Tutorials/CMake
it fails when you run catkin_make.
So I'm still stuck with Melodic!
:-(

@jagyer
Please Try this , using patch file to update msg.h automatically
simple add this line

execute_process(COMMAND patch ${CMAKE_CURRENT_BINARY_DIR}/ros_lib/ros/msg.h ${CMAKE_CURRENT_SOURCE_DIR}/patch/msg.patch)

after rosserial_configure_client command in your CMakeLists.txt
and create file msg.patch under your project_folder/patch with content:

40c40
< #include <cstring>
---
> #include <string.h>
68c68
<     std::memcpy(&val, &f, sizeof(val));
---
>     memcpy(&val, &f, sizeof(val));
182c182
<     std::memcpy(f, &val, sizeof(val));
---
>     memcpy(f, &val, sizeof(val));

At least for now...

The #525 works well for me finally .... It's very helpful !

I can confirm as well, this was the solution working for me.

Still no success with rosserial_arduino using Cmake for me :-/ I can build Arduino code under ROS Noetic using the Arduino IDE and ros_lib from Rosserial Arduino Library by Michael Ferguson version 0.7.9. However, since I'm also using Raspberry Pi running Ubuntu Server 20.04 and ROS Noetic now (works great!), in headless mode, it would be really convenient to be able to build arduino firmware using the Cmake tool in ROS from commandline!
I just tried out the proposed solution by xVanTuring above. Thanks for that! It makes a lot of sense, and it was so clearly described that even I should be able to understand, but ... nope.
I will try it out out soon on a completely "untouched" system also. I might have screwed things up on my system by trying various solution suggestions. But "everything" else in ROS, except for rosserial_arduino, seems to function. Maybe I'm just missing something "obvious"...?
It's a pity though that developers haven't fixed this yet, in the official updates! As it seems...Last installation of Noetic I made was just a couple of weeks ago. Same issue.... But I still have my laptop with Melodic on it, and it works as it should!

@jagyer
Please Try this , using patch file to update msg.h automatically
simple add this line

execute_process(COMMAND patch ${CMAKE_CURRENT_BINARY_DIR}/ros_lib/ros/msg.h ${CMAKE_CURRENT_SOURCE_DIR}/patch/msg.patch)

after rosserial_configure_client command in your CMakeLists.txt
and create file msg.patch under your project_folder/patch with content:

40c40
< #include <cstring>
---
> #include <string.h>
68c68
<     std::memcpy(&val, &f, sizeof(val));
---
>     memcpy(&val, &f, sizeof(val));
182c182
<     std::memcpy(f, &val, sizeof(val));
---
>     memcpy(f, &val, sizeof(val));

At least for now...

This worked for me, thank you very much!

Maybe this can help a bit.

Remove folder ros_lib inside libraries directory.
Then got to Arduino IDE->Sketch->Include Library->Manage Libraries... ( Ctrl+Shift+I )
And search for "rosserial" and install: Rosserial Arduino Library by Michael Ferguson

Using version 0.7.9, worked with fresh new Arduino Uno and Arduino Mega. Also able to compile for Seeeduino Zero (integrated on Odyssey X86J4105)

this worked for me! thanks a lot

Try this.
In libraries\Rosserial_Arduino_Library\src\ros\msg.h

replace #include <cstring> with the following code and romove std:: of std::memcpy

#include <string.h>    

void memcpy(void *dest, void *src, size_t n)  
{  
   char *csrc = (char *)src;  
   char *cdest = (char *)dest;  
   for (int i=0; i<n; i++)  
       cdest[i] = csrc[i];  
}

Hello I'm using Arduino IDE 1.8.13 and Arduino Uno When I try to verify/compile the HelloWorld example I'm getting this error in the IDE:

In file included from /home/user/Arduino/libraries/ros_lib/std_msgs/Time.h:7:0,
                 from /home/user/Arduino/libraries/ros_lib/ros/node_handle.h:40,
                 from /home/user/Arduino/libraries/ros_lib/ros.h:38,
                 from /home/user/Arduino/libraries/ros_lib/examples/HelloWorld/HelloWorld.pde:6:
/home/user/Arduino/libraries/ros_lib/ros/msg.h:40:10: fatal error: cstring: No such file or directory
 #include <cstring>
          ^~~~~~~~~
compilation terminated.
exit status 1
Error compiling for board Arduino Uno.

Instead of using newer version of rosserial in arduino library, i used older version 0.7.9. It worked for me

@jagyer Please Try this , using patch file to update msg.h automatically simple add this line

execute_process(COMMAND patch ${CMAKE_CURRENT_BINARY_DIR}/ros_lib/ros/msg.h ${CMAKE_CURRENT_SOURCE_DIR}/patch/msg.patch)

after rosserial_configure_client command in your CMakeLists.txt and create file msg.patch under your project_folder/patch with content:

40c40
< #include <cstring>
---
> #include <string.h>
68c68
<     std::memcpy(&val, &f, sizeof(val));
---
>     memcpy(&val, &f, sizeof(val));
182c182
<     std::memcpy(f, &val, sizeof(val));
---
>     memcpy(f, &val, sizeof(val));

At least for now...

it works thank you

It really works , Thanks .