Using GNU autoconf/automake to build RTI Connext DDS Applications

RTI Connext DDS includes several examples that demonstrate the capabilities of the product. Those examples can be found in the workspace (created automatically when you launch any Connext DDS application), or generated using rtiddsgen (with the option -example), or online through our community portal Github account.

Most of the examples include either a set of Makefiles (for building on Linux systems), Visual Studio project and workspace files (for building on Windows), others include a cmake script. 

This article introduces a new tool (connext-config) that will facilitate the creation of build systems for RTI Connext DDS applications written in C and C++ using the popular tool chain GNU Autoconf and Automake.

The typical challenges with building a C/C++ application for RTI Connext DDS can be summarized as follows:

  • Find the correct location of the RTI Connext DDS headers
  • Provide the compiler with the correct macros defining the target architecture and the correct flags
  • Identify the library location given the target architecture
  • Correctly identify the name of the RTI Connext DDS libraries for a given platform and variants (static/dynamc, debug/release)
  • Provide the linker with the correct flags for the selected target

The GNU ecosystem provides a popular tool called 'pkg-config' that facilitates building applications that depend on a particular framework/library. RTI has implemented a similar utility called `connext-config` that helps answer all the challenges listed above.
Similar to GNU's `pkg-config`, the `connext-config` tool is a command-line utility that can be invoked to request useful things for a given target platform, such as:
  • The name of the compiler to use
  • The flags to pass to the compiler
  • The name of the linker to use
  • The flags to pass to the linker
  • The RTI Connext DDS libraries and system libraries required to complete the build



connext-config

The `connext-config` utility is not officially supported by RTI and is available only through our Github Community page: https://github.com/rticommunity/connext-config.

You can either download the source and build it (using autoconf/automake), or just download a pre-built image that you can un-tar on top of your existing RTI Connext DDS installation directly from here: https://github.com/rticommunity/connext-config/releases:

Assuming you are using Connext DDS 6.0.1 and you downloaded version 1.0.3 of connext_config (the current version at the time of writing this document), from your '~/Downloads' folder, run these commands:

 

$ cd rti_connext_dds-6.0.1
$ tar xvzf ~/Downloads/connext-config-1.0.3.tar.gz

 

That's it! The archive contains binaries for both Linux and macOS hosts and a launcher script that gets installed automatically under the `bin` directory of your RTI Connext DDS installation.

The `connext-config` tool does not depend on any particular version of RTI Connext DDS, as it automatically retrieves all the target flags and library information from the RTI Connext DDS installation itself (to be specific, it parses and reads the same macro file used by `rtiddsgen` when launched with the -example option).

You can uncompress the connext-config tar file directly on top of any RTI Connext DDS installation!
The tool has been successfully tested with:

  • RTI Connext DDS 5.3.0
  • RTI Connext DDS 6.0.0
  • RTI Connext DDS 6.0.1
 
 

Autoconf Macros to use connext-config

If you look at the `examples` directory of the connext-config project, you will find the following examples:

  • autoconf-hello
    This is the same `hello` C application that is part of your RTI workspace, but it uses autoconf/automake to invoke connext-config and generate a build file.

  • autoconf-hello-idl-cpp
    Similarly, this is the same `hello` C++ application that is part of your RTI workspace, but it uses autoconf/automake.

  • cmake-requestreply
    This is the C++ request-reply example (again from the RTI workspace) that uses cmake to retrieve the build settings using `connext-config`.

 

Both autoconf-based examples include an m4 macro (under each example's m4 directory) that you can copy into your projects. This macro does the following:

  • Locates where RTI Connext DDS is installed, either by looking at the `configure` parameter `--with-rticonnextdds=<location>` or (if not provided) at the environment variable $NDDSHOME. If RTI Connext DDS cannot be located, it prints an error and stops execution of the `configure` script.

  • Confirms that the tool `connext-config` is accessible. By default, it looks under the RTI Connext DDS installation, but you can override it using the option `--with-connext-config=<path>`.

  • Lets you specify that you want to link against the RTI Connext DDS static libraries vs. dynamic libraries (option `--with-rticonnextdds-static`).

  • Allows you to define the target architecture to use for the build (`--enable-target=<target>`).

  • Invokes connext-config multiple times to locate compiler, linker, libraries and settings.

 

To use this macro, just include it from your `configure.ac`:

 

...

m4_include([m4/rticonnextdds.m4])

... 

 

Use one of the two examples as a reference or starting point for your autoconf-based project.

Remember to:

  • Use the m4 macro from the `autoconf-hello-idl-cpp` if you are building an application in C++ (traditional C++).

  • Use the m4 macro from `autoconf-hello` if you are building an application in C.

  • If you are using Modern C++, start from the `autoconf-hello-idl-cpp` and modify the m4 macro to change the command-line arguments to `connext-config` to request material for Modern C++:

...
CC="`${CONNEXT_CONFIG} --cxx03comp ${NDDSARCH}`"
LD="`${CONNEXT_CONFIG} --cxx03link ${NDDSARCH}`"
CFLAGS="$CFLAGS `${CONNEXT_CONFIG} $RTICFG_STATIC $RTICFG_DEBUG --cxx03flags ${NDDSARCH}`"
LDFLAGS="`${CONNEXT_CONFIG} $RTICFG_STATIC $RTICFG_DEBUG --ldxx03flags ${NDDSARCH}`"
LIBS="$LDFLAGS `${CONNEXT_CONFIG} $RTICFG_STATIC $RTICFG_DEBUG --ldxx03libs ${NDDSARCH}`"

  • Similarly, if you use C++11, replace the above flags with --cxx11comp, --cxx11link, --cxx11flags, --ldxx11flags, and --ldxx11libs. 

Refer to the examples README.md for additional information.