Note: This tutorial assumes that you have completed the previous tutorials: Mingw Build Environment.

Mingw Packages

Description: How to create ros packages that can also be compiled by the mingw_cross compiler.

Keywords: mingw

Tutorial Level: INTERMEDIATE

Next Tutorial: Mingw Qt-Ros Packages

New in electric

Not available

Not available.

Goal

Configure a regular ros package to be ready for a mingw cross compile.

Even if you're looking to create qt apps, this is still necessary if your msg/srv packages are kept separate (recommended). You may however want to skip to the qt tutorial and come back to this one.

Create the Package

Set up your package as you would usually do for rosbuild1 somewhere in your source tree, e.g.

> roscreate-pkg foo

Confirm that you can build natively (rosbuild1 style) with the usual make command.

Configuring for Rosbuild2

The next step is to make the package rosbuild2 compatible.

Manifest

This involves adding a small excerpt to your manifest.xml which deals with:

  • ros package dependencies
  • system dependencies (rosdeps)
  • msg/srv exports

An example (from qt_tutorials):

<rosbuild2>
   <!-- private dependencies -->
   <depend package="qt_build"/>
   <!-- ros dependencies -->
   <depend package="roscpp"/>
   <depend package="std_msgs"/>
   <!-- system dependencies -->
   <rosdep name="qt4"/>
   <!-- msg/srv's -->
   <srvs>srv/TwoInts.srv</srvs>
</rosbuild2>

CMake

You'll need an alternative CMakeLists.txt for when your project detects rosbuild2.

The usual method is to insert an alternative call at the top of your CMakeLists.txt:

if(ROSBUILD)  
  # This is the rosbuild2 path
  include(rosbuild.cmake OPTIONAL)
  return()
endif()

# CMake for rosbuild1 should follow this as normal.

In rosbuild.cmake put the rosbuild2 compatible cmake. Most of the function calls are essentially the same - the only really big difference is that msg and srv generation is no longer needed in the cmake itself - it's automatic.

Most of the fundamental ros packages have this embedded already - browse the CMakeLists.txt and rosbuild.cmake in packages such as cpp_common, rostime, roscpp for examples. Keep in mind that the cmake for rosbuild2 is stored in the cmake stack, not rosbuild.

Building

If everything is all ok, you should be able to build a native version in the source tree (rosbuild1)

> roscd foo
> make

and a mingw compiled version in the rosbuild2 parallel build directory (refer to the mingw build environment tutorial.

> cd ~/mingwros/build
> cmake .      # cmake has to rerun to discover your new package
> cd foo
> make -j5     # -jx for number of parallel jobs

Overview

Creating a new package or converting an old one so that it can be mingw cross compiled requires that it be catkinized.

This is quite different to the old rosbuild style development for packages, and it is also important to note, that once catkinized, it can't be built with the traditional rosbuild technique.

For more details on how to do this, refer to the guide on catkinization.

Wiki: mingw_cross/Tutorials/Mingw Packages (last edited 2012-05-11 05:39:35 by DanielStonier)