rosserial icon indicating copy to clipboard operation
rosserial copied to clipboard

cstring: No such file or directory

Open shmulike opened this issue 4 years ago • 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.

shmulike avatar Sep 11 '20 16:09 shmulike

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...

jagyer avatar Sep 13 '20 16:09 jagyer

Hi Still didn't find any solution for that

shmulike avatar Sep 13 '20 16:09 shmulike

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.

dmitriypoyarkov avatar Sep 22 '20 10:09 dmitriypoyarkov

the same problem

RuslanNig avatar Sep 22 '20 22:09 RuslanNig

Hi I have the same issue

fadamsyah avatar Sep 26 '20 16:09 fadamsyah

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)

Guasch5000 avatar Sep 28 '20 14:09 Guasch5000

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

fadamsyah avatar Oct 01 '20 14:10 fadamsyah

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 avatar Oct 07 '20 19:10 jagyer

@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...

xVanTuring avatar Jan 14 '21 11:01 xVanTuring

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

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

RBinsonB avatar Jan 21 '21 09:01 RBinsonB

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 avatar Feb 05 '21 14:02 jagyer

@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!

viso951 avatar Mar 13 '21 17:03 viso951

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

WilliBobadilla avatar Apr 04 '21 15:04 WilliBobadilla

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];  
}

OttawaSTEM avatar Jul 25 '21 22:07 OttawaSTEM

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

adarsha-s-bharadwaj avatar Apr 01 '22 08:04 adarsha-s-bharadwaj

@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

mertbacaksiz avatar Jan 29 '23 11:01 mertbacaksiz

It really works , Thanks .

Aman-rkl avatar Feb 07 '24 17:02 Aman-rkl