Compiling or cross-compiling using CMake

Compiling using CMake

Follow the steps below to compile NAOqi SDK examples.

  1. Be sure that the NAOqi executable and modules packages are not running.
  2. Launch the CMake interface.
  3. In the "Where is the code source" field , select the example directory of the NAOqi SDK (example: "/path/to/aldebaran-sdk/modules/src/examples/helloworld").
  4. In the "Where to build the binaries" field , select a temporary build directory. Create it if it doesn't exist (example: "/path/to/aldebaran-sdk/modules/modules/src/examples/helloworld/build").
  5. Click on the "configure" button. Select the IDE to be used : "Visual Studio 8 2005" or "Visual Studio 9 2008" on Windows, or "UNIX Makefiles" on Linux or Mac.
  6. Select the choice "Specify toolchain file for cross-compiling" and enter /path/to/aldebaran-sdk/toolchain-pc.cmake.
    Note:

    You must specify a toolchain file even if you're not cross-compiling.

  7. If some configuration fields are red, click again on the "configure" button. All fields must be gray to be OK.
  8. Click on OK.
  9. On Windows, a .sln file will be generated in you build directory, ready to be opened.
  10. Compile the example project. On Linux or Mac, simply "cd" to the build directory and type "make"
Note:

At anytime, you can reset your project by deleting contents of the build directory and relaunch CMake.

Please do not edit the visual studio project, because it is generated on the fly (see cmake documentation for details). Configuration can be done by editing the cmake files.

If you don't have cmake-gui on Linux, you can use the following commands to configure cmake:

$~ cd /path/to/sources $~ mkdir build $~ cd build $~ cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/aldebaran-sdk/toolchain.cmake .. $~ ccmake . # Optional, useful to change cmake's options $~ make

Cross-compiling using CMake

In order to have your code running on NAO, you have to cross-compile it. Right now this is only possible on Linux. Cross-compilation is needed to ensure compilation is done with correct optimisation flags and links with correct libraries versions.

Warning:

You no longer have the rights to write in /opt/naoqi/. You should put your personnal data in /home/nao.

  1. Download and extract the latest Aldebaran cross-toolchain from the Users site, and save it in /path/to/ctc/. The cross-toolchain contains everything needed to compile naoqi modules as well as other libraries and binaries for the robot.
  2. A toolchain-geode.cmake is available in the root folder of the archive. This toolchain-geode.cmake will be passed to cmake instead of toolchain-pc.cmake. This is the only difference between cross-compilation and compilation.
  3. Configure cmake in a crossbuild directory (for example buildcross instead of build), and specify the toolchain-geode.cmake file as the toolchain file
  4. The following steps are the same as for compiling.
  5. Example:

    $~ cd /path/to/sources $~ mkdir buildcross $~ cd buildcross $~ cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/ctc/toolchain-geode.cmake .. $~ make

Debugging

  • On Linux, you have to configure CMake (using ccmake or the cmake-gui), and set the CMAKE_BUILD_TYPE variable to "DEBUG"
  • On Windows, you just have to select "debug" as the build configuration.
    Warning:

    The "MinSizeRel" and the "RelWithDebugInfo" configurations are not officially supported.





Copyright © 2010 Aldebaran-Robotics - All rights reserved