Hi,
I'm experiencing with the service_as_library example for Recording Service from here: https://github.com/rticommunity/rticonnextdds-examples/tree/master/examples/recording_service/service_as_lib/cpp
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)
project(ServiceAsLib)
-if(NOT BUILD_SHARED_LIBS)
- 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})
-endif()
-
if(NOT CMAKE_BUILD_TYPE)
set(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")
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(recording_lib "${recording_lib}d")
endif()
@@ -106,7 +99,10 @@ target_include_directories(
target_link_libraries(
ServiceAsLibExample
- RTIConnextDDS::cpp2_api
+ nddsmetpz
+ nddscpp2z
+ nddscz
+ nddscorez
"${recordingservicelib}"
${CONNEXTDDS_EXTERNAL_LIBS}
)
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.
Attachment | Size |
---|---|
make_log.txt | 1.94 MB |
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
rti_connext_dds-6.0.1\resource\cmake\FindRTIConnextDDS.cmake
to see how you may want to modify the CMakeLists.txt to add the definitions. Maybe adding:
add_definitions("${CONNEXTDDS_COMPILE_DEFINITIONS}")
is sufficient.