Ask Your Question

Rosserial Arduino Compilation Error: No <CSTRING>

asked 2020-09-20 10:05:47 -0500

ytosclee gravatar image

updated 2020-09-20 10:06:53 -0500

Hi, I am using Ubuntu 20.04 and ROS Noetic. I followed the rosserial tutorial arduino setup page but I cannot compile the ros_lib HelloWorld example in Arduino. It gives me the following error. I am not able to resolve it and I would like to ask for your help! Thanks a lot!

    In file included from /home/kk/Arduino/libraries/ros_lib/std_msgs/Time.h:7:0,
                 from /home/kk/Arduino/libraries/ros_lib/ros/node_handle.h:40,
                 from /home/kk/Arduino/libraries/ros_lib/ros.h:38,
                 from /home/kk/Arduino/libraries/ros_lib/examples/HelloWorld/HelloWorld.pde:6:
/home/kk/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 Leonardo.
edit retag flag offensive close merge delete


8 Answers

Sort by ยป oldest newest most voted

answered 2020-09-27 00:09:00 -0500

groscore gravatar image

Hey, I ran into the same issue and after hours of searching google, I found the following workaround:

First you have to delete the ros_lib folder that was created when you initially ran rosrun rosserial_arduino . It should be located in /home/Arduino/libraries or wherever you installed arduino IDE.

Then open the Arduino IDE, in the menu bar go to Tools -> Manage Libraries and search for "rosserial"

You should see Rosserial Arduino Library by Michael Furguson. Install it, I installed 0.7.9

Now you can try to compile your HellowWorld program again and it should work.

Not sure why this worked but hopefully it works for you too.

edit flag offensive delete link more


Thanks, it solves my problem.

ytosclee gravatar image ytosclee  ( 2020-09-30 20:51:04 -0500 )edit

I found that I had to use 0.7.9 as listed above. version 0.9.4 had the same issue.

PeterMilani gravatar image PeterMilani  ( 2021-01-23 20:09:28 -0500 )edit

I got this error from installing the rosserial library through the Arduino IDE library manager. but if i instead ran the python script as the comment explains above (or, taken from this link:, everything works fine.

traemand gravatar image traemand  ( 2021-06-10 03:43:23 -0500 )edit

answered 2021-05-29 13:02:34 -0500

Saad_Ahmed gravatar image

Just edit the msg.h file located Arduino/libraries/Rosserial_Arduino_Library/src/ros in line 40 write #include <string.h> and in line 68 and 182 remove std:: before memcpy

Hope this will work for you

edit flag offensive delete link more


Hey, this works but why this changes? can you explain

Raj_28 gravatar image Raj_28  ( 2021-09-03 22:47:10 -0500 )edit

answered 2020-09-28 03:29:37 -0500

Was5K gravatar image

Hi ytoclee

Got same issue here when installing arduino libraries using:

rosrun rosserial_arduino

Just delete the folder 'ros_lib' inside arduino libraries. Then, inside Arduino IDE, Sketch/Include Library/Manage Libraries... search by "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)

Let me know if this solves your problem ;)

edit flag offensive delete link more


Thanks, it solves my problem.

ytosclee gravatar image ytosclee  ( 2020-09-30 20:50:29 -0500 )edit

answered 2020-11-06 12:04:40 -0500

Alexander Tadiashvili gravatar image

updated 2021-02-17 20:18:41 -0500

I faced the same problem and solved it by changing the "msg.h" in ~/Arduino/libraries/ros_lib/ros destination generated by rosrun rosserial_arduino . with "msg.h" file from "rosserial lib" (0.7.8 version) which was downloaded from the Library manager of Arduino IDE (directory of this file in downloaded library: ~/Rosserial_Arduino_Library/src/ros/).

If you don't have any custom messages you want to use in your Arduino IDE you can download the full "rosserial" library from the Library Manager.

edit flag offensive delete link more


thanks, follow your steps and solve the problem.

Arnolvalencia1 gravatar image Arnolvalencia1  ( 2021-03-11 11:37:57 -0500 )edit

answered 2021-07-19 04:25:00 -0500

Yash Sahu gravatar image

updated 2021-08-04 00:30:16 -0500

I didn't find any ros_lib folder as mentioned in above answers. But fixed it. the problem is in your ros/msg.h file #include <cstring> no longer works, replace it with #include <string.h> and the std::memcpy() function is not a part of std anymore, so change it to memcpy().

Summary: (Changes) File - ros/msg.h

  1. Change -> #include <cstring> to #include <string.h>
  2. Change -> std::memcpy() to memcpy()

And it will work!

edit flag offensive delete link more

answered 2020-12-26 23:28:53 -0500

VAHID gravatar image

Step 1 :

Extract and copy in home and run ./arduino

vahid@vahid:~/arduino-1.8.13$ ./arduino

Step 2 :

sudo apt-get install ros-indigo-rosserial-arduino sudo apt-get install ros-indigo-rosserial

Step 3 :

cd <ws>/src git clone cd <ws> catkin_make catkin_make install</ws></ws>

Step 4 :

Generate ROS library

Open two terminal : Terminal 1 : $ Run roscore

Terminal 2 : vahid@vahid:~$ cd arduino-1.8.13/ vahid@vahid:~/arduino-1.8.13$ cd libraries/ vahid@vahid:~/arduino-1.8.13/libraries$ rm -rf ros_lib vahid@vahid:~/arduino-1.8.13/libraries$ rosrun rosserial_arduino .

Then open the Arduino IDE, in the menu bar go to Tools -> Manage Libraries and search for "rosserial"

You should see Rosserial Arduino Library by Michael Furguson and install 0.7.9

Step 5 : How to run :

vahid@vahid:~/arduino-1.8.13$ ./arduino

Go to example find ros_lib and based on your application run example codes.

For example open HelloWorld and compile after that open one terminal

vahid@vahid:~/catkin_ws$ rosrun rosserial_python /dev/ttyUSB0

Open other terminal and type rostopic list. You can see chatter topic

vahid@vahid:~/catkin_ws$ rostopic list /chatter

edit flag offensive delete link more

answered 2020-09-25 09:21:31 -0500

Shivantanu gravatar image

Install "StandardCplusplus-master" library in Arduino. Copy 'cstring.c' and 'cstdef.c' from "StandardCplusplus-master" to ros-lib. You can run all code and rosrun rosserial_python /dev/ttyACM0 succesfully without any error.

edit flag offensive delete link more

answered 2020-09-27 17:41:09 -0500

Glyn Webster gravatar image

Hello! I came here looking for the same answer.

The problem is that the ros_lib/ros/msg.h file that ROS puts in the Arduino directory uses <cstring>, the C++ version of <string.h>. Arduino does not recognise that for some reason.

After changing <cstring> to <string.h> and changing all occurances of std::memcpy to just memcpy everything compiled.

That change will disappear next time I update ros_lib, of course, so I'm still keen to know what the right thing to do is.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2020-09-20 10:05:47 -0500

Seen: 4,942 times

Last updated: Aug 04