Note before: All this was tested using the orocos 1.0.x branch and xenomai v2.2.x branch. OCL (which uses the cmake build system) was not yet tested.
Warning: These instructions are not meant for the faint of hart :)
Suppose the root file system of your target board is mounted at ${DESTDIR}, and e.g. xenomai is installed at ${DESTDIR}/usr/xenomai, and the linux sources for your target at ${DESTDIR}/usr/src/linux, then do the following:
- Copy the boost headers from your host to ${DESTDIR}/usr/include/boost. Since the boost source code checks for defines set by the compiler, you can simply copy its headers without cross compiling boost first
- Make a build directory and run configure. Tell it to use your cross compiler, e.g.
CC=/path/to/your/crosscompiler-gcc CXX=/path/to/your/crosscompiler-g++ CPPFLAGS="-I ${DESTDIR}/usr/include/" ../configure --build=`../config/config.guess` --host=the_name_of_your_target --with-xenomai=${DESTDIR}/usr/xenomai/ --with-linux=${DESTDIR}/usr/src/linux CXXFLAGS="-I${DESTDIR}/usr/include/" CFLAGS="-I${DESTDIR}/usr/include/"
e.g. compiling for amd64 this could be
CC=/path/to/amd64-linux-gnu-gcc CXX=/path/to/amd64-linux-gnu-g++ [...] --host=amd64-linux-gnu [...]
Note that orocos will use the tinyXML code now (unless you also cross compiled xerces-c before) and won't compile the tests (unless you also cross compiled cppunit for your target). - Embedded is your middle name, so you probably want to use the "make configure_packages" target, don't you?
- Go baby:
make && make install DESTDIR=${DESTDIR}
Your first application:
The orocos-apps directory contains some examples using simple makefiles, which can be easily adapted for cross-compiling. The simple-task example is a good place to start. If you comment out the lines regarding the TaskBrowser, you can test some taskcontext stuff without needing OCL.
Note: Unfortunately, pkgconfig
pkgconfig is not very suited for cross compiling, see this thread and this (not yet implemented) proposal. However, you can bypass it by using the --define-variable switch
. E.g. when you installed orocos in ${DESTDIR}/usr/local/orocos, you can use
pkgconfig --define-variable=prefix=${DESTDIR}/usr/local/orocos your_other_options_here
to get things working.