Goal

This is for the control roboticists who love working in linux and get flustered when asked to build windows apps for the rest of the world (namely users/test engineers). It also allows a write once, compile in linux and windows approach to developing gui programs when used with qt.

Installation

Prep

If you haven't already, install the ros build environment python packages:

# Install from apt-get
> sudo apt-get install python-rosdep python-rosinstall python-rospkg python-empy python-nose
# If you haven't initialised rosdep yet
> sudo rosdep init
> rosdep update

Sources

For now, cross-compiling with mingw is done completely from source with rosinstall. It does not use a binary (e.g. deb) based repository.

> rosinstall --catkin ~/win/src https://raw.github.com/stonier/win_ros/master/mingw_fuerte.rosinstall

This .rosinstall file is useful as a reference to start adding your own stacks to the rosinstall. The typical use case for mingw programs is just to communicate to the linux ros control platform, so ordinarily you'll only need to add msg/srv stacks to the above rosinstaller.

Note that we're using catkin now - which is essentially a purely cmake solution that will utilise a src and parallel build directory. It will also mean that your packages must be upgraded for catkin compiles. While transitioning from rosbuild to catkin this may be an issue, if so - you may wish to use electric until more stacks are converted to catkin.

Finally, apply the currently held patches (most of these are in the middle of getting merged upstream):

> cd ~/win/src
> ./win_ros/win_patches/apply_mingw_patches

Toolchain

Installing the mingw_cross toolchain to ~/mingw (you can modify installation location by setting MINGW_INSTALL_PREFIX):

> cd ~/win/src/win_ros/mingw/mingw_cross
> # Not working with catkin and rosdep2 yet, but should later
> # rosdep install mingw_cross
> # Instead, make sure you have the dependencies installed, e.g. ubuntu:
> sudo apt-get install mercurial xz-utils flex bison yasm autoconf libtool intltool scons
> make install

This takes quite some time. To speed things up with parallel jobs, edit the Makefile and set the JOBS variable.

In addition, it will add the variables MINGW_ROOT, MINGW_CMAKE_TOOLCHAIN_FILE and MINGW_CMAKE_ROS_CONFIG_FILE and update your PATH in ~/.bashrc.

Catkin

Compilation

# In case you forgot to do earlier
> cd ~/win
> mkdir build
> cd build
> cmake 
    -DCMAKE_TOOLCHAIN_FILE=${MINGW_CMAKE_TOOLCHAIN_FILE} 
    -C ${MINGW_CMAKE_ROS_CONFIG_FILE} 
    ../src
> cd ros_tutorials/roscpp_tutorials; make -j5; cd ..
> cd qt_ros/qt_tutorials; make -j5; cd ..

Note that the bash variables are defined in ~/.bashrc for convenience (see above). The -j# option sets up parallel builds which is useful for speeding things up on a multi-core system.

Modifying the Build

> cd ~/win/build
> ccmake .

You can then change variables such as the build type (actually, that's probably the only one you really want to modify.

Running

All the binaries are built statically. That means they are entirely self-sufficient and standalone. It also means they're big, but as we're primarily using these just for monitoring and debugging purposes, optimisation isn't a big deal.

Simply copy the binaries in ~/win/build/bin or ~/win/build/_stack_/_package_/bin to your windows machine. Fire up a roscore on a linux machine and then run the qt tutorials - make sure you enter the correct variables for the ROS_MASTER_URI and ROS_IP. Alternatively you can just start a windows shell and set the environment variables before running any of the roscpp/qt tutorials.

Wiki: mingw_cross/Mingw Build Environment - Fuerte (last edited 2012-08-08 13:57:44 by DanielStonier)