This is how I managed to cross-compile groovy
for the beagleboard-XM
running debian-armhf/stable
.
It requires that you already have a groovy functional version on the host and a corresponding catkin_workspace containing the sources.
it is of course not the only way to proceed, but it worked for me.
it is tested under the following environment:
host system: debian-amd64/wheezy. groovy installed in /opt/ros/groovy
target system: debian-armhf/wheezy. groovy will be installed in /opt/ros/beagleboard
on the host system,
the cross-compiler must be installed.
edit and update the sources.list
to add the emdebian
repository
deb <a href="http://www.emdebian.org/debian/">http://www.emdebian.org/debian/</a> unstable main
install gcc for armhf
sudo apt-get install g++-4.7-arm-linux-gnueabihf
groovy must be prepared to be cross-compiled.
create a copy of the groovy workspace for armhf.
(customize the path if required)
cp -rv ~/robot/ros/catkin_workspace_amd64 ~/robot/ros/catkin_workspace_armhf
create the configuration file configuration ros_armhf_toolchain.cmake
from rosbuild/rostoolchain.cmake
cd ~/robot/ros/catkin_workspace_armhf
cp -v ./src/rosbuild/core/rosbuild/rostoolchain.cmake ./src/rosbuild/core/rosbuild/ros_armhf_toolchain.cmake
edit the file to update the following variables
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_C_COMPILER /usr/bin/arm-linux-gnueabihf-gcc-4.7)
set(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabihf-g++-4.7)
set(CMAKE_INSTALL_PREFIX /opt/ros/beagleboard)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH /usr/arm-linux-gnueabihf) # armhf dependencies install dir
set(CATKIN_ENABLE_TESTING OFF) # enable if required
install the missing libraries
(you may work in a chroot
if you prefer)
sudo xapt --keep-cache -a armhf -m libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libpython2.7 python2.7-dev libboost-signals-dev libboost-regex-dev libboost-date-time-dev libboost-thread-dev liblog4cxx10-dev libtinyxml-dev libbz2-dev libeigen3-dev libtiff-dev libassimp-dev libpoco-dev
There's perhaps a cleaner way to perform this step, but I did not find it.
Copy the environment files from groovy
mkdir -p /opt/ros/beagleboard
cd /opt/ros/groovy
cp -v env.sh setup.bash setup.sh _setup_util.py setup.zsh /opt/ros/beagleboard
edit setup.sh to replace /opt/ros/groovy with /opt/ros/beagleboard
cd /opt/ros/beagleboard
launch a first compilation
(you may of course add other packages)
source setup.bash
cd ~/robot/ros/catkin_workspace_armhf
./src/catkin/bin/catkin_make_isolated --pkg roslib roscpp rostime rosconsole roscpp_serialization xmlrpcpp message_filters tf actionlib_msgs actionlib catkin rosbash roslaunch rosparam rosservice rostest rostopic topic_tools rosmsg rosbag genpy rospkg genmsg rosclean rosgraph_msgs rosmaster rosout rosgraph std_msgs --install --install-space /opt/ros/beagleboard -DCMAKE_TOOLCHAIN_FILE=~/robot/ros/catkin_workspace_armhf/src/rosbuild/core/rosbuild/ros_armhf_toolchain.cmake -DCMAKE_VERBOSE_MAKEFILE=true \
-DCMAKE_BUILD_TYPE=Debug
at this step, this first compilation ended because of linker errors.
Edit the following files to replace groovy with beagleboard
(you may also use awk for that)
cd ~/robot/ros/catkin_workspace_armhf
vi build_isolated/rosconsole/CMakeFiles/rosconsole.dir/link.txt
vi build_isolated/roscpp/CMakeFiles/roscpp.dir/link.txt
vi build_isolated/tf/CMakeFiles/tf.dir/link.txt
vi build_isolated/tf/CMakeFiles/pytf_py.dir/link.txt
vi build_isolated/tf/CMakeFiles/static_transform_publisher.dir/link.txt
vi build_isolated/tf/CMakeFiles/testBroadcaster.dir/link.txt
vi build_isolated/tf/CMakeFiles/tf_change_notifier.dir/link.txt
vi build_isolated/tf/CMakeFiles/tf_echo.dir/link.txt
vi ...
(more)