0
$\begingroup$

Rosanswers logo

I've come across a bit of a linking problem when trying to get Arduino projects compiled for my ROS electric installation under Ubuntu.

When compiling for ROS, rosmake / CMake somehow sneaks the "-rdynamic" flag into the linking arguments for the object files regardless of target. This normally isn't a problem but since I've updated gcc-avr to 4.7.0 its behaviour is now set to error out when it finds an unsupported option, previous versions simply gave a warning and continued on. Manually removing -rdynamic from link.txt inside the relevant CMakeFiles folder then making fixes the problem and the linking is successful, but that defeats the purpose of CMake if I have to do that every time.

The easy solution would be to downgrade gcc-avr to the previous version (it's not like I need the new version) but I'm interested where in the CMake process is this flag getting set and how the link.txt script is actually generated for individual packages, I can't seem to find any documents regarding this. I've done a plaintext search on the stack source files and "rdynamic" doesn't show up, it has to appear somewhere higher up the chain.

-- UPDATE --

Thought I'd add that I'm compiling my Arduino projects via the Poark port of the parsec.rosserial stack as I found the official rosserial_arduino version under Electric to be utterly broken when I checked it out a few months ago, things may have changed since then but I've been working around this stack and it hasn't faulted me yet.

I ended up reverting gcc-avr to version 4.5.3 along with a compatible avr-libc. "-rdynamic" no longer crashes the build script and everything works mostly as it should with Poark. Rosmake is only for initially setting up rosserial, after that you call cmake directly.

The process involves calling cmake with a bunch of Arduino specific flags (mcu type, speed, upload port etc), this is easily done with a bash script. Poark's cmake script then does its thing and generates Makefiles for your Arduino project leaving you to invoke 'make upload' to generate binaries and upload them to the board.

I did however find a curious issue when I invoked 'make'; it executes a cmake_check_build_system function inside the Makefile which regenerates the Makefile without the Arduino specific options, making the script fall over as no 3rd party Arduino libraries are in the compiler scope. This was resolved by altering the bash script to remove the offending function from the Makefile after generation using sed and before the user has a chance to invoke 'make upload'

Anyhow, I think I'd consider this question closed. It seems that the original problem stems from CMake throwing flags in at a fundamental level and gcc-avr 4.7.0 just being pedantic. To fix this bug would probably mean breaking a lot of 'normal' cases, so reverting and staying would be the best option.

It would be interesting to see if the newer build environments in Groove can do Arduino support out of the box when it is released, or if official rosserial_arduino can be fixed (but I hear only very few people work on that module)

Thanks to all who contributed.


Originally posted by Bertrix on ROS Answers with karma: 61 on 2012-06-07

Post score: 1


Original comments

Comment by Eric Perko on 2012-06-07:
So... you are trying to compile Arduino code using rosmake?

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

-rdynamic appears to be added by CMake automatically on Linux. For example, http://www.cmake.org/pipermail/cmake/2009-October/032948.html .

I don't think rosmake has very good support for cross-compiling right now (I've never actually tried it though), so it doesn't surprise me if it's picking up flags that are inappropriate for Arduino (by assuming that the target is a Linux system).

You may want to look at http://www.ros.org/wiki/eros . There are resources there for how to cross-compile ROS packages (but I believe they are still targeting embedded Linux systems, not Arduinos).

rosserial, specifically rosserial_arduino, may have some resources for compiling ROS packages for Arduino that you could build on/reference.

The new catkin build system should also have better support for cross-compiling, however catkin isn't scheduled for full release until at least ROS Groovy.


Originally posted by Eric Perko with karma: 8406 on 2012-06-07

This answer was ACCEPTED on the original site

Post score: 2

$\endgroup$

Your Answer

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