Rosanswers logo

When I compile the "Hello World" example in the Arduino IDE I get this message:

HelloWorld.cpp.o: In function global constructors keyed to nh': HelloWorld.cpp:31: undefined reference to ros::normalizeSecNSec(unsigned long&, unsigned long&)' collect2: ld returned 1 exit status

I arrived at this point after painstakingly editing the code of every file in the relevant sequence so that every #include "(some_file_name)" reference contained the full directory address to fix "No such file or directory" error messages. So:




And it seemed to be working (at least it stopped throwing up those error messages) but I can't figure this error out. I'm stuck. Any help would be greatly appreciated.

Thanks for the input, Cody. I've mirrored the formatting as it is in the files and it seems to have worked. Those errors looked a bit like this"

HelloWorld.cpp:7:29: fatal error: std_msgs/String.h: No such file or directory compilation terminated.

This one is a bit different as it refers to a line of code directly in the "Hello World".pde file. Following the same tactic as before I modified it from:

#include <std_msgs/Strings.h>


#include </home/ryan/sketchbook/libraries/std_msgs/Strings.h>

When I do this the compiler posts the error message I listed right at the top of my post. I don't know if this means I fixed that problem and am on to the next, or if the modification caused this error. I'm wondering if the IDE can't locate everything in my sketchbook for some reason. I assume I messed up something on the setup but I had no errors there that I could tell and the IDE sees the ros example files just fine, they're listed in its menus. Either way I'm still stuck.

[Originally posted](https://answers.ros.org/question/34193/arduino-ide-compile-error-"...undefined-reference-to-`ros::normalizesecnsec(unsigned-long&..."/) by RyanG on ROS Answers with karma: 26 on 2012-05-16

Post score: 0

Original comments

Comment by Cody on 2012-05-16:
Can you post all of the errors and warnings you get? I expect if the change in #include "ros/msg.h" changes things, we'll see some other items. Also, if you want code to format properly, wrap it in backticks or indent it with 4 spaces.

Comment by RyanG on 2012-05-17:
Thanks, Cody. I've updated my post. The forum's displaying the code lines all screwy and I can't change it. No idea why. They should look like this. #include <std_msgs strings.h> and #include </home/ryan/sketchbook/libraries/std_msgs/Strings.h>

Comment by Bkat on 2017-04-25:
Have there been any updates on the potential root cause? I've tried a bunch of solutions but nothing seems to work.


1 Answer 1


Rosanswers logo

After Third re-install I got it to work. Don't know why though.

Originally posted by RyanG with karma: 26 on 2012-05-17

This answer was ACCEPTED on the original site

Post score: 0


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.