3. Linux installation from sources

The instructions for installing the Fast DDS library, the Fast DDS Python bindings and the Fast DDS-Gen generation tool from sources are provided in this page. It is organized as follows:

3.1. Fast DDS library installation

This section describes the instructions for installing eProsima Fast DDS in a Linux environment from sources. The following packages will be installed:

  • foonathan_memory_vendor, an STL compatible C++ memory allocator library.

  • fastcdr, a C++ library that serializes according to the standard CDR serialization mechanism.

  • fastrtps, the core library of eProsima Fast DDS library.

First of all, the Requirements and Dependencies detailed below need to be met. Afterwards, the user can choose whether to follow either the colcon or the CMake installation instructions.

3.1.1. Requirements

The installation of eProsima Fast DDS in a Linux environment from sources requires the following tools to be installed in the system:

3.1.1.1. CMake, g++, pip3, wget and git

These packages provide the tools required to install eProsima Fast DDS and its dependencies from command line. Install CMake, g++, pip3, wget and git using the package manager of the appropriate Linux distribution. For example, on Ubuntu use the command:

sudo apt install cmake g++ python3-pip wget git

3.1.2. Dependencies

eProsima Fast DDS has the following dependencies, when installed from sources in a Linux environment:

See also

For further information about this Fast DDS version dependencies, as well as for the corresponding versions of other related products, please refer to the Fast DDS Library dependencies section.

3.1.2.1. Asio and TinyXML2 libraries

Asio is a cross-platform C++ library for network and low-level I/O programming, which provides a consistent asynchronous model. TinyXML2 is a simple, small and efficient C++ XML parser. Install these libraries using the package manager of the appropriate Linux distribution. For example, on Ubuntu use the command:

sudo apt install libasio-dev libtinyxml2-dev

3.1.2.2. OpenSSL

OpenSSL is a robust toolkit for the TLS and SSL protocols and a general-purpose cryptography library. Install OpenSSL using the package manager of the appropriate Linux distribution. For example, on Ubuntu use the command:

sudo apt install libssl-dev

3.1.2.3. Libp11 and SoftHSM libraries

Libp11 provides PKCS#11 support for OpenSSL. This is an optional dependency, that is needed only when eprosima Fast DDS is used with security and PKCS#11 URIs.

Install libp11 using the package manager of the appropriate Linux distribution. For example, on Ubuntu use the command:

sudo apt install libp11-dev

SoftHSM is a software implementation of an HSM (Hardware Security Module). If eProsima Fast DDS tests are activated and libp11 is installed on the system, SoftHSM is additionally required to run tests of PKCS#11 features.

Install SoftHSM using the package manager of the appropriate Linux distribution. For example, on Ubuntu use the command:

sudo apt install softhsm2

Note that the softhsm2 package creates a new group called softhsm. In order to grant access to the HSM module a user must belong to this group.

sudo usermod -a -G softhsm <user>

OpenSSL access HSM and other hardware devices through its engine functionality. In order to set up a new engine the OpenSSL configuration files (usually /etc/ssl/openssl.cnf) must be updated specifying the libp11 and hardware module (here SoftHSM) dynamic libraries location.

This configuration step can be avoided using p11kit which allows OpenSSL to find PKCS#11 devices on runtime without static configuration. This kit is often available through the Linux distribution package manager. On Ubuntu, for example:

sudo apt install libengine-pkcs11-openssl

Once installed, to check p11kit is able to find the SoftHSM module use:

p11-kit list-modules

In order to check if OpenSSL is able to access PKCS#11 engine use:

openssl engine pkcs11 -t

3.1.2.4. Gtest

GTest is a unit testing library for C++. By default, eProsima Fast DDS does not compile tests. It is possible to activate them with the opportune CMake configuration options when calling colcon or CMake. For more details, please refer to the CMake options section. Also add the Gtest repository into the workspace directory.

git clone --branch release-1.11.0 https://github.com/google/googletest src/googletest-distribution

3.1.2.5. XML validation tool

XML validation is a new command introduced to validate the XML profiles against an XSD schema through Fast DDS CLI. That ensures the proper characterization of the entities using the xml profiles.

For more details, please refer to the xml section.

Install the xmlschema dependency to be able to use this optional tool.

3.1.3. Colcon installation

colcon is a command line tool based on CMake aimed at building sets of software packages. This section explains how to use it to compile eProsima Fast DDS and its dependencies.

  1. Install the ROS 2 development tools (colcon and vcstool) by executing the following command:

    pip3 install -U colcon-common-extensions vcstool
    

    Note

    Mind that under non-root users, pip3 may install python colcon and vcs executables in $HOME/.local/bin, for instance when running with --user. To be able to run these applications, make sure that pip3 binary installation directory is in your $PATH ($HOME/.local/bin is normally introduced while login on an interactive non-root shell).

  2. Create a Fast-DDS directory and download the repos file that will be used to install eProsima Fast DDS and its dependencies:

    mkdir ~/Fast-DDS
    cd ~/Fast-DDS
    wget https://raw.githubusercontent.com/eProsima/Fast-DDS/master/fastrtps.repos
    mkdir src
    vcs import src < fastrtps.repos
    
  3. Build the packages:

    colcon build
    

Note

Being based on CMake, it is possible to pass CMake configuration options to the colcon build command. For more information on the specific syntax, please refer to the CMake specific arguments page of the colcon manual.

3.1.3.1. Run an application

When running an instance of an application using eProsima Fast DDS, the colcon overlay built in the dedicated Fast-DDS directory must be sourced. There are two possibilities:

  • Every time a new shell is opened, prepare the environment locally by typing the command:

    source ~/Fast-DDS/install/setup.bash
    
  • Add the sourcing of the colcon overlay permanently to the PATH, by typing the following:

    echo 'source ~/Fast-DDS/install/setup.bash' >> ~/.bashrc
    

3.1.4. CMake installation

This section explains how to compile eProsima Fast DDS with CMake, either locally or globally.

3.1.4.1. Local installation

  1. Create a Fast-DDS directory where to download and build eProsima Fast DDS and its dependencies:

    mkdir ~/Fast-DDS
    
  2. Clone the following dependencies and compile them using CMake.

    • Foonathan memory

      cd ~/Fast-DDS
      git clone https://github.com/eProsima/foonathan_memory_vendor.git
      mkdir foonathan_memory_vendor/build
      cd foonathan_memory_vendor/build
      cmake .. -DCMAKE_INSTALL_PREFIX=~/Fast-DDS/install -DBUILD_SHARED_LIBS=ON
      cmake --build . --target install
      
    • Fast CDR

      cd ~/Fast-DDS
      git clone https://github.com/eProsima/Fast-CDR.git
      mkdir Fast-CDR/build
      cd Fast-CDR/build
      cmake .. -DCMAKE_INSTALL_PREFIX=~/Fast-DDS/install
      cmake --build . --target install
      
  3. Once all dependencies are installed, install eProsima Fast DDS:

    cd ~/Fast-DDS
    git clone https://github.com/eProsima/Fast-DDS.git
    mkdir Fast-DDS/build
    cd Fast-DDS/build
    cmake ..  -DCMAKE_INSTALL_PREFIX=~/Fast-DDS/install
    cmake --build . --target install
    

Note

By default, eProsima Fast DDS does not compile tests. However, they can be activated by downloading and installing Gtest.

3.1.4.2. Global installation

To install eProsima Fast DDS system-wide instead of locally, remove all the flags that appear in the configuration steps of Fast-CDR and Fast-DDS, and change the first in the configuration step of foonathan_memory_vendor to the following:

-DCMAKE_INSTALL_PREFIX=/usr/local/ -DBUILD_SHARED_LIBS=ON

Note

Installation on system directories may need of permissions. Maybe permissions have to be granted through sudo.

sudo cmake --build . --target install

3.1.4.3. Run an application

When running an instance of an application using eProsima Fast DDS, it must be linked with the library where the packages have been installed, which in the case of system-wide installation is: /usr/local/lib/ (if local installation is used, adjust for the correct directory). There are two possibilities:

  • Prepare the environment locally by typing the command:

    export LD_LIBRARY_PATH=/usr/local/lib/
    
  • Add it permanently it to the PATH, by typing:

    echo 'export LD_LIBRARY_PATH=/usr/local/lib/' >> ~/.bashrc
    

3.2. Fast DDS Python bindings installation

This section provides the instructions for installing Fast DDS Python bindings in a Linux environment from sources. Fast DDS Python bindings is an extension of Fast DDS which provides access to the Fast DDS API through Python. Therefore, its installation is an extension of the installation of Fast DDS.

Fast DDS Python bindings source code consists on several .i files which will be processed by SWIG. Then C++ files (for connecting C++ and Python) and Python files (Python module for Fast DDS) will be generated.

First of all, the Requirements and Dependencies detailed below need to be met. Afterwards, the user can choose whether to follow either the colcon or the CMake installation instructions.

3.2.1. Requirements

The installation of Fast DDS Python bindings in a Linux environment from sources requires the following tools to be installed in the system:

3.2.1.1. SWIG

SWIG is a development tool that allows connecting programs written in C/C++ with a variety of other programming languages, among them Python. SWIG 4.0 is required in order to build Fast DDS Python bindings.

Note

More recent SWIG releases are not yet supported. Please, ensure to be using SWIG 4.0.

SWIG can be installed directly from the package manager of the appropriate Linux distribution. For Ubuntu, please run:

sudo apt install swig

3.2.1.2. Header files and static library for Python

Python static libraries and header files are needed to compile C++ source code generated by SWIG. They can be installed directly from the package manager of the appropriate Linux distribution. For Ubuntu, please run:

sudo apt install libpython3-dev

3.2.2. Dependencies

Fast DDS Python bindings has the following dependencies, when installed from sources in a Linux environment:

3.2.3. Colcon installation

colcon is a command line tool based on CMake aimed at building sets of software packages. This section explains how to use it to compile Fast DDS Python bindings and its dependencies.

  1. Install the ROS 2 development tools (colcon and vcstool) by executing the following command:

    pip3 install -U colcon-common-extensions vcstool
    

    Note

    If this fails due to an Environment Error, add the --user flag to the pip3 installation command.

  2. Create a Fast-DDS-python directory and download the repos file that will be used to install Fast DDS Python bindings and its dependencies:

    mkdir ~/Fast-DDS-python
    cd ~/Fast-DDS-python
    wget https://raw.githubusercontent.com/eProsima/Fast-DDS-python/main/fastdds_python.repos
    mkdir src
    vcs import src < fastdds_python.repos
    
  3. Build the packages:

    colcon build
    

Note

Being based on CMake, it is possible to pass CMake configuration options to the colcon build command. For more information on the specific syntax, please refer to the CMake specific arguments page of the colcon manual.

3.2.3.1. Run an application

When running an instance of an application using Fast DDS Python bindings, the colcon overlay built in the dedicated Fast-DDS-python directory must be sourced. There are two possibilities:

  • Every time a new shell is opened, prepare the environment locally by typing the command:

    source ~/Fast-DDS-python/install/setup.bash
    
  • Add the sourcing of the colcon overlay permanently to the PATH, by typing the following:

    echo 'source ~/Fast-DDS-python/install/setup.bash' >> ~/.bashrc
    

3.2.4. CMake installation

This section explains how to compile Fast DDS Python bindings with CMake, either locally or globally.

3.2.4.1. Local installation

  1. Create a Fast-DDS-python directory where to download and build Fast DDS Python bindings and its dependencies:

    mkdir ~/Fast-DDS-python
    
  2. Clone the following dependencies and compile them using CMake.

    • Foonathan memory

      cd ~/Fast-DDS-python
      git clone https://github.com/eProsima/foonathan_memory_vendor.git
      mkdir foonathan_memory_vendor/build
      cd foonathan_memory_vendor/build
      cmake .. -DCMAKE_INSTALL_PREFIX=~/Fast-DDS-python/install -DBUILD_SHARED_LIBS=ON
      cmake --build . --target install
      
    • Fast CDR

      cd ~/Fast-DDS-python
      git clone https://github.com/eProsima/Fast-CDR.git
      mkdir Fast-CDR/build
      cd Fast-CDR/build
      cmake .. -DCMAKE_INSTALL_PREFIX=~/Fast-DDS-python/install
      cmake --build . --target install
      
    • Fast DDS

      cd ~/Fast-DDS-python
      git clone https://github.com/eProsima/Fast-DDS.git
      mkdir Fast-DDS/build
      cd Fast-DDS/build
      cmake .. -DCMAKE_INSTALL_PREFIX=~/Fast-DDS-python/install
      cmake --build . --target install
      
  3. Once all dependencies are installed, install Fast DDS Python bindings:

    cd ~/Fast-DDS-python
    git clone https://github.com/eProsima/Fast-DDS-python.git
    mkdir -p Fast-DDS-python/fastdds_python/build
    cd Fast-DDS-python/fastdds_python/build
    cmake ..  -DCMAKE_INSTALL_PREFIX=~/Fast-DDS-python/install
    cmake --build . --target install
    

3.2.4.2. Global installation

To install Fast DDS Python bindings system-wide instead of locally, remove all the flags that appear in the configuration steps of Fast-CDR, Fast-DDS and Fast-DDS-python, and change the first in the configuration step of foonathan_memory_vendor to the following:

-DCMAKE_INSTALL_PREFIX=/usr/local/ -DBUILD_SHARED_LIBS=ON

Note

Installation on system directories may need of permissions. Maybe permissions have to be granted through sudo.

sudo cmake --build . --target install

3.2.4.3. Run an application

When running an instance of an application using Fast DDS Python bindings, it must be linked with the library where the packages have been installed, which in the case of system-wide installation is: /usr/local/lib/ (if local installation is used, adjust for the correct directory). There are two possibilities:

  • Prepare the environment locally by typing the command:

    export LD_LIBRARY_PATH=/usr/local/lib/
    
  • Add it permanently it to the PATH, by typing:

    echo 'export LD_LIBRARY_PATH=/usr/local/lib/' >> ~/.bashrc
    

3.3. Fast DDS-Gen installation

This section provides the instructions for installing Fast DDS-Gen in a Linux environment from sources. Fast DDS-Gen is a Java application that generates source code using the data types defined in an IDL file. Please refer to Introduction for more information.

3.3.1. Requirements

Fast DDS-Gen is built using Gradle. Gradle is an open-source build automation tool which requires a Java version to be executed (see Gradle-Java compatibility matrix).

Important

Even though earlier versions of Gradle support Java 8, Fast DDS-Gen stopped supporting Java versions previous to Java 11 since release v2.4.0.

Important

Fast DDS-Gen introduced support for Gradle 7 in release v2.2.0. Gradle 8 is not yet supported.

See also

For further information about Fast DDS-Gen product related versions, please refer to the Library dependencies section.

3.3.1.1. Java JDK

The JDK is a development environment for building applications and components using the Java language. There are several versions of Java available. For instance, to install Java 11 JDK, run the following command:

sudo apt install openjdk-11-jdk

Note

Fast DDS-Gen supports Java versions from 11 to 19.

3.3.2. Compiling Fast DDS-Gen

In order to compile Fast DDS-Gen, an executable script is included in the repository which will download Gradle temporarily for the compilation step. Please, follow the steps below to build Fast DDS-Gen:

Note

If Fast DDS has already been installed following Colcon installation, skip cloning Fast DDS-Gen’s repository, as it can already be found under the src directory within the colcon workspace.

cd ~
git clone --recursive https://github.com/eProsima/Fast-DDS-Gen.git
cd Fast-DDS-Gen
./gradlew assemble

Note

In case that a supported Gradle version is already installed in the system, Fast DDS-Gen can also be built running directly:

gradle assemble

3.3.2.1. Contents

The Fast-DDS-Gen folder contains the following packages:

  • share/fastddsgen, where the generated Java application is.

  • scripts, containing some user friendly scripts.

    Note

    To make these scripts accessible from any shell session and directory, add the scripts folder path to the PATH environment variable.