gpt4 book ai didi

build - OpenDDS 项目的 cmake

转载 作者:行者123 更新时间:2023-12-02 22:57:04 29 4
gpt4 key购买 nike

寻找标准 CMakelist 来构建 OpenDDS 应用程序(简单发布者/订阅者)。我熟悉教程,并且使用 MPC 构建示例的一切都运行良好。我需要使用 cmake 构建我的项目。我正在使用 OpenDDS 3.9。

我尝试为此处的 Stockquote 示例创建一个 CMakelist: http://opendds.org/about/articles/Article-Intro.html

我的 CMakelist 如下所示:

cmake_minimum_required (VERSION 3.3.0)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
project (publisher)
set(DDS_ROOT_DIR "home/ubuntu/OpenDDS-3.9")

set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin)

include_directories (${DDS_ROOT_DIR} "${DDS_ROOT_DIR}/ACE_wrappers" "${DDS_ROOT_DIR}/ACE_wrappers/TAO" ${CMAKE_SOURCE_DIR})

file (GLOB_RECURSE PUBLISHER_SRC *.cpp)
file (GLOB_RECURSE IDL_SRC ${CMAKE_SOURCE_DIR} *.cpp)

add_executable (${PROJECT_NAME} ${PUBLISHER_SRC} ${IDL_SRC})

project (subscriber)

set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin)

include_directories (${DDS_ROOT_DIR} "${DDS_ROOT_DIR}/ACE_wrappers" "${DDS_ROOT_DIR}/ACE_wrappers/TAO" ${CMAKE_SOURCE_DIR})

file (GLOB_RECURSE SUBSCRIBER_SRC *.cpp)
file (GLOB_RECURSE IDL_SRC ${CMAKE_SOURCE_DIR} *.cpp)

add_executable (${PROJECT_NAME} ${SUBSCRIBER_SRC} ${IDL_SRC})

# Adding DDS link_libraries
if (WIN32)
file (GLOB OpenDDS_LIBS "${DDS_ROOT_DIR}/lib/*d.dll")
foreach (i ${OpenDDS_LIBS})
get_filename_component (BASE_NAME_DLL ${i} NAME_WE)
add_library (${BASE_NAME_DLL} SHARED IMPORTED)
set_property (TARGET ${BASE_NAME_DLL} PROPERTY IMPORTED_LOCATION "${DDS_ROOT_DIR}/lib/${BASE_NAME_DLL}.dll")
set_property (TARGET ${BASE_NAME_DLL} PROPERTY IMPORTED_IMPLIB "${DDS_ROOT_DIR}/lib/${BASE_NAME_DLL}.lib")
target_link_libraries (${PROJECT_NAME} ${BASE_NAME_DLL})
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:${BASE_NAME_DLL}> $<TARGET_FILE_DIR:${PROJECT_NAME}>)
endforeach()

file (GLOB OpenDDS_LIBS "${DDS_ROOT_DIR}/ACE_wrappers/lib/*d.dll")
foreach (i ${OpenDDS_LIBS})
get_filename_component (BASE_NAME_DLL ${i} NAME_WE)
add_library (${BASE_NAME_DLL} SHARED IMPORTED)
set_property (TARGET ${BASE_NAME_DLL} PROPERTY IMPORTED_LOCATION "${DDS_ROOT_DIR}/ACE_wrappers/lib/${BASE_NAME_DLL}.dll")
set_property (TARGET ${BASE_NAME_DLL} PROPERTY IMPORTED_IMPLIB "${DDS_ROOT_DIR}/ACE_wrappers/lib/${BASE_NAME_DLL}.lib")
target_link_libraries (${PROJECT_NAME} ${BASE_NAME_DLL})
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:${BASE_NAME_DLL}> $<TARGET_FILE_DIR:${PROJECT_NAME}>)
endforeach ()
elseif (UNIX)
file (GLOB OpenDDS_LIBS "${DDS_ROOT_DIR}/lib/*.so")
foreach (i ${OpenDDS_LIBS})
get_filename_component (BASE_NAME_DLL ${i} NAME_WE)
add_library (${BASE_NAME_DLL} SHARED IMPORTED)
set_property (TARGET ${BASE_NAME_DLL} PROPERTY IMPORTED_LOCATION "${DDS_ROOT_DIR}/lib/${BASE_NAME_DLL}.so")
target_link_libraries (${PROJECT_NAME} ${BASE_NAME_DLL})
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:${BASE_NAME_DLL}> $<TARGET_FILE_DIR:${PROJECT_NAME}>)
endforeach()
file (GLOB OpenDDS_LIBS "${DDS_ROOT_DIR}/ACE_wrappers/lib/*.so")
foreach (i ${OpenDDS_LIBS})
get_filename_component (BASE_NAME_DLL ${i} NAME_WE)
add_library (${BASE_NAME_DLL} SHARED IMPORTED)
set_property (TARGET ${BASE_NAME_DLL} PROPERTY IMPORTED_LOCATION "${DDS_ROOT_DIR}/ACE_wrappers/lib/${BASE_NAME_DLL}.so")
target_link_libraries (${PROJECT_NAME} ${BASE_NAME_DLL})
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:${BASE_NAME_DLL}> $<TARGET_FILE_DIR:${PROJECT_NAME}>)
endforeach ()
endif ()

我从 WTeam 博客获取了添加 DDS 链接库部分。 http://www.wteam.it/index.php/articles/the-hla-series/9-article/15-first-opendds-program

目前,如果我使用 cmake --build,我会收到此错误消息:

/usr/local/include/dds/DCPS/DataWriterImpl_T.h: In instantiation of ‘void OpenDDS::DCPS::DataWriterImpl_T::init(DDS::Topic_ptr, OpenDDS::DCPS::TopicImpl*, const DDS::DataWriterQos&, DDS::DataWriterListener_ptr, const StatusMask&, OpenDDS::DCPS::DomainParticipantImpl*, OpenDDS::DCPS::PublisherImpl*, DDS::DataWriter_ptr) [with MessageType = Messenger::Message; DDS::Topic_ptr = DDS::Topic*; DDS::DataWriterListener_ptr = DDS::DataWriterListener*; DDS::StatusMask = unsigned int; DDS::DataWriter_ptr = DDS::DataWriter*]’: /usr/local/include/dds/DCPS/FilterEvaluator.h:142:10: required from here /usr/local/include/dds/DCPS/DataWriterImpl_T.h:317:50: error: incomplete type ‘OpenDDS::DCPS::DataWriterImpl_T::MarshalTraitsType {aka OpenDDS::DCPS::MarshalTraits}’ used in nested name specifier if (MarshalTraitsType::gen_is_bounded_size()) { ^ /usr/local/include/dds/DCPS/DataWriterImpl_T.h:323:54: error: incomplete type ‘OpenDDS::DCPS::DataWriterImpl_T::MarshalTraitsType {aka OpenDDS::DCPS::MarshalTraits}’ used in nested name specifier if (MarshalTraitsType::gen_is_bounded_key_size()) { ^ /usr/local/include/dds/DCPS/DataWriterImpl_T.h: In instantiation of ‘DDS::ReturnCode_t OpenDDS::DCPS::DataWriterImpl_T::enable_specific() [with MessageType = Messenger::Message; DDS::ReturnCode_t = int]’: /usr/local/include/dds/DCPS/FilterEvaluator.h:142:10: required from here /usr/local/include/dds/DCPS/DataWriterImpl_T.h:338:51: error: incomplete type ‘OpenDDS::DCPS::DataWriterImpl_T::MarshalTraitsType {aka OpenDDS::DCPS::MarshalTraits}’ used in nested name specifier if (MarshalTraitsType::gen_is_bounded_size ()) ^

有人知道出了什么问题或者有 OpenDDS 应用程序的标准 CMake 吗?非常感谢您的帮助。

干杯,马塞尔

最佳答案

OpenDDS 3.14 将支持 cmake,请参阅 https://github.com/objectcomputing/OpenDDS/tree/master/tests/cmake_integration使用 cmake 进行单元测试。

关于build - OpenDDS 项目的 cmake,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46650141/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com