Compiling the OpenRDK framework
NOTE: if you are using a downloaded version up to 2.1.5 beta, or if you are using a Subversion checkout up to revision 275, please follow the instructions here, otherwise, you can read below.
This page contains the instructions about how to compile the OpenRDK framework. This will enable us to begin using the framework to develop our code. OpenRDK compilation is performed in two steps: you first generate
Makefiles (i.e., the instructions for the compiler, such as source file dependencies, libraries to link, etc.) and then you actually compile the framework.
The first step is performed, in OpenRDK, using the well-known
cmake software. Recent OpenRDK releases do not allow in-source builds: you must compile out-of-source (if this does not make sense for you, just read the following instructions).
With out-of-source builds, you are able to compile for different platforms without the need to have different source trees (e.g., you can compile OpenRDK for your machine and cross-compile for another). Cross-compilation is needed, for example, if you want to compile OpenRDK libraries and modules for Nao's Geode platform.
cmake to generate
This method leaves the
src directories clean and allows for multiple builds (e.g., cross-platform builds).
First of all, go in the root directory of the OpenRDK (it should be named
OpenRDK, if you followed the instruction in the previous Installation page) and create the build directory (the
ls command is just to make you sure that you are in the right directory):
COPYING src/ data/ docs/
$ mkdir build
This directory is the output tree of the compiled version of the OpenRDK framework (i.e., object files, applications, libraries, etc.). If you need also to cross-compile for another platform, just create another directory (e.g.,
build-geode) and repeat the process (of course you need to change the build settings accordingly, see the cross-building page).
Now you are ready to generate the
Makefiles, issuing the following commands:
$ cd build
$ cmake ../src
build directory contains all files that are needed to compile the OpenRDK framework.
At anytime you can configure the compilation process by using
$ ccmake .
It will present a screen like this:
CMAKE_BUILD_TYPE option specifies the type of building (Debug or Release).
CMAKE_INSTALL_PREFIX option informs the path where the building will be performed.
COMPILATION_FLAGS option determines the flag passed to the g++ for building the sources.
COMPILE_* options enable or disable the compilation of specific portion of OpenRDK, like the Nao libraries or RConsole. You can choose to include some of them, or exclude them. For example, RConsole requires the qt libraries, that in an embedded system could be no available. Here you can avoid the inclusion fo such parts.
ENABLE_* options are mainly for enabling advanced feature (you can safely skip them).
ROOT_* options are used to add a path in case a specific library is installed in a non-standard path (like for the Aldabaran SDK). Not all the library support them yet.
When you are satisfied with the configuration, you can actually configure it by pressing
[c]. Then press
[g] to generate the Makefiles.
Now you can proceed as before to the compilation.
NOTE: you need to issue the
cmake command only if something changes in the source tree (e.g., a new module is added).
Now you can start the compilation process:
If everything is working, you should see the fancy colored output of the CMake-based compilation process.
After building the OpenRDK framework, two new directories will be created in the
bin directory, all the binaries for running OpenRDK applications are placed. This directory will be added to your
PATH variable (see the following sections).
lib directory, all the built libraries required for running OpenRDK are placed (these will be added to your
DYLD_LIBRARY_PATH so that the system knows where to find the required libraries and modules, see the following sections).
NOTE: you will use the
make command every time you change some of the source files of the OpenRDK framework, or when you update the source tree using Subversion (
As we said in the previous section, in order for your system to properly find applications, libraries and modules that belong to the OpenRDK framework, you must set some environment variables accordingly. This is achieved using a convenient utility called
rdkenv. In order to easily use it, you have to install that in one of the system search path for commands. This is obtained (in the same
build directory where you run
$ make install_rdkenv
This will show you a set of directories that are in your search path, you will choose among them where to put the
rdkenv. You will be given also some advices about which directory to use. However, if you want to put the
rdkenv script in a directory where it is available to all users of your computer, you need root users privileges, i.e., you must run the
make install_rdkenv command being the root user. This is achieved, in a Debian-like distribution (such as, for example, Ubuntu), by:
$ sudo make install_rdkenv
In this case, you will see that more directories are writable, so that you can install
rdkenv in one of the preferred ones.
In order to test if the script has been correctly installed in your system, try to run this command:
$ rdkenv list
This should show a list of OpenRDK environments currently installed in your system (usually, only one).
Setting the OpenRDK environment
After installing the
rdkenv script in your system, you are free to use it to set the OpenRDK environment before you can start OpenRDK applications. This means that before launching
rconsoleqt or whatever other OpenRDK executable or script, you must say to your system where to look for those executables/scripts. This is achieved by simply typing:
$ . rdkenv
Please note that it is
. (dot) followed by a space and then
rdkenv. This is a shortcut for
source rdkenv. The above command will set the environment to the default. Since you did not choose a default environment yet, the first time you run this command you will probably have an output like this:
The default environment has not been chosen yet: setting /some/OpenRDK/environment/directory as the default environment.
The default OpenRDK environment is now /some/OpenRDK/environment/directory.
Setting OpenRDK environment to /some/OpenRDK/environment/directory.
The first line says that no OpenRDK environment has been chosen as default (yet). The behavior of the script is to choose the first of the installed environments as default environment (this will be done only once). The second line says that this has been done successfully. Finally, the default OpenRDK environment is set: this means that the shell environment variables (e.g.,
$LD_LIBRARY_PATH) have been set accordingly. Now you can run
ragent2, other applications and other scripts that belongs to this build.
If you have other builds, i.e., other environments, you can choose aliases for them and set one of them using a command like this:
$ . rdkenv set somealias
For a better documentation on the
rdkenv script, type:
$ rdkenv help
You will also learn the commands to install new environments (this is usually done automatically when
cmake is run), remove them, setting the default environment, create an alias, and so on.
NOTE: when you set an OpenRDK environment, the previous environment variables are cleaned from previous OpenRDK-related information.