Compiling or cross-compiling using CMake
Compiling using CMake
Follow the steps below to compile NAOqi SDK examples.
- Be sure that the NAOqi executable and modules packages are not running.
- Launch the CMake interface.
- In the field , select the example directory of the NAOqi SDK (example: "/path/to/aldebaran-sdk/modules/src/examples/helloworld").
- In the field , select a temporary build directory. Create it if it doesn't exist (example: "/path/to/aldebaran-sdk/modules/modules/src/examples/helloworld/build").
- Click on the 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.
- 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.
- If some configuration fields are red, click again on the button. All fields must be gray to be OK.
- Click on OK.
- On Windows, a .sln file will be generated in you build directory, ready to be opened.
- 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. |
---|
- 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.
- 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.
- Configure cmake in a crossbuild directory (for example buildcross instead of build), and specify the toolchain-geode.cmake file as the toolchain file
- The following steps are the same as for compiling.
- 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.