Search code examples
buildidlgenerateopendds

Is There a Way to Generate Code for OpenDDS


I know that RTI has a code generator to create the publisher and subscriber which then allow you to create DataReaders and DataWriters. Is there any way to generate the needed code in OpenDDS? I have already established the idl file that lists the topics to be transmitted and I see here: https://objectcomputing.com/resources/publications/mnb/code-generation-with-opendds-part-i provides instructions to generate a wrapper but I am still not understanding if there is a way to simply build the idl file so that it generates the publisher and subscriber files needed for the OpenDDS architecture. For example RTI has rtiddsgen.

When I build the file using only Messenger.idl the error message comes up:

-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19041.
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - not found
-- Found Threads: TRUE
-- Configuring done
CMake Error at CMakeLists.txt:15 (add_executable):
  Cannot find source file:

    Publisher.cpp

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx


CMake Error at CMakeLists.txt:22 (add_executable):
  Cannot find source file:

    Subscriber.cpp

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx


CMake Error at CMakeLists.txt:15 (add_executable):
  No SOURCES given to target: publisher


CMake Error at CMakeLists.txt:22 (add_executable):
  No SOURCES given to target: subscriber

The cmake file looks like this:


    project(OpenDDS_DevGuide_Messenger CXX)
cmake_minimum_required(VERSION 3.8.2)

find_package(OpenDDS REQUIRED)

set(CMAKE_CXX_COMPILER ${OPENDDS_COMPILER})

set(opendds_libs
  OpenDDS::Dcps # Core OpenDDS Library
  OpenDDS::InfoRepoDiscovery OpenDDS::Tcp # For run_test.pl
  OpenDDS::Rtps OpenDDS::Rtps_Udp # For run_test.pl --rtps
)

# Publisher
add_executable(publisher
  Publisher.cpp
)
OPENDDS_TARGET_SOURCES(publisher Messenger.idl)
target_link_libraries(publisher ${opendds_libs})

# Subscriber
add_executable(subscriber
  Subscriber.cpp
  DataReaderListenerImpl.cpp
)
OPENDDS_TARGET_SOURCES(subscriber Messenger.idl)
target_link_libraries(subscriber ${opendds_libs})

Solution

  • Yes, OpenDDS has a code generator, opendds_idl, which is one of OpenDDS's core components. It can run manually, through MPC, or in CMake using OPENDDS_TARGET_SOURCES like you have here.

    The error is pretty self explanatory. This is the CMakeLists.txt file from the Developer's Guide Messenger example, which includes C++ files. CMake can't find them. Maybe you copied CMakeLists.txt somewhere else without also copying the cpp files? If so you can copy the cpp files to where you copied CMakeLists.txt.