Linking Recording service library statically

2 posts / 0 new
Last post
Last seen: 1 week 1 day ago
Joined: 03/29/2021
Posts: 3
Linking Recording service library statically


I'm experiencing with the service_as_library example for Recording Service from here:

In my case, I'd like to link all the RTI Connext libraries to the executable statically, so I've made some changes to CMakeLists.txt provided by the example. Here's my modification:

diff --git a/examples/recording_service/service_as_lib/cpp/CMakeLists.txt b/examples/recording_service/service_as_lib/cpp/CMakeLists.txt
index 4a96de20..342568d6 100644
--- a/examples/recording_service/service_as_lib/cpp/CMakeLists.txt
+++ b/examples/recording_service/service_as_lib/cpp/CMakeLists.txt
@@ -12,13 +12,6 @@
 cmake_minimum_required(VERSION 3.11)
-    set(msg
-        "Static linking is not supported for this example. You can build it "
-        "using the -DBUILD_SHARED_LIBS=ON CMake parameter")
-    message(FATAL_ERROR ${msg})
         "Not specifying CMAKE_BUILD_TYPE can lead to undefined behaviour and "
@@ -52,7 +45,7 @@ find_package(
 # Select the adequate version of the Recording Service library depending on the
 # build type
-set(recording_lib "rtirecordingservice")
+set(recording_lib "rtirecordingservicez")
     set(recording_lib "${recording_lib}d")
@@ -106,7 +99,10 @@ target_include_directories(
-    RTIConnextDDS::cpp2_api
+    nddsmetpz
+    nddscpp2z
+    nddscz
+    nddscorez


However, I still meet build errors when compiling the code with these modifications. The make log is in attached file. I'm using RTI Connext Pro 6.0.1 on Ubuntu 18.04.

Please help. Thanks in advanced.

Plain text icon make_log.txt1.94 MB
Howard's picture
Last seen: 5 days 16 hours ago
Joined: 11/29/2012
Posts: 177

From the errors, I would guess that your CMAKE configuration isn't pulling in the required compiler macros, such as RTI_UNIX, need to configure the header files to build for Linux or Windows or etc.

You can look through the file


to see how you may want to modify the CMakeLists.txt to add the definitions.  Maybe adding:


is sufficient.