目录概述相关资源安装前置依赖使用 vcpkg 编译 Fast DDS编译 Fast DDS Spy编译 Shapes Demo创建独立运行目录使用指南常见问题1. 概述什么是 eProsima Fast DDS?Fast DDS原名 Fast RTPS是 eProsima 开发的一个高性能 DDSData Distribution Service数据分发服务实现。DDS 是 OMGObject Management Group制定的分布式实时中间件标准广泛应用于机器人、自动驾驶、工业物联网、航空航天等领域。RTPS 协议: 基于 Real-Time Publish-Subscribe (RTPS) 协议提供高效的数据分发语言支持: C API应用场景: ROS 2 的默认中间件、自动驾驶、仿真系统、工业控制什么是 Fast DDS Spy?Fast DDS Spy是一个 DDS 网络监控工具可以发现 DDS 网络中的DomainParticipants和Topics实时监控Topic 数据支持YAML 配置文件提供CLI 交互模式什么是 Shapes Demo?Shapes Demo是 eProsima Fast DDS 的官方演示程序通过可视化的彩色几何图形圆形、正方形、三角形展示 DDS 的发布/订阅通信机制。2. 相关资源项目官网GitHub 仓库Fast DDSeprosima.comgithub.com/eProsima/Fast-DDSFast DDS Spyfast-dds-spy.readthedocs.iogithub.com/eProsima/Fast-DDS-SpyDDS Pipedds-pipe.readthedocs.iogithub.com/eProsima/DDS-PipeShapes Demo—github.com/eProsima/ShapesDemoFast DDS Python—github.com/eProsima/Fast-DDS-python3. 安装前置依赖3.1 系统要求Windows 10/11 x64Visual Studio 2022Professional / CommunityCMake ≥ 3.20Ninja可选用于加速编译GitChocolatey可选用于安装依赖3.2 安装 Chocolatey如未安装以管理员身份运行 PowerShellSet-ExecutionPolicy Bypass -Scope Process -Force [System.Net.ServicePointManager]::SecurityProtocol [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 iex ((New-Object System.Net.WebClient).DownloadString(https://community.chocolatey.org/install.ps1))3.3 安装 Visual Studio 2022确保安装时勾选“使用 C 的桌面开发”工作负载包含 MSVC v143 构建工具和 Windows 10/11 SDK。设置 VS2022 环境变量的批处理脚本本教程的工作目录假设为 C:\Users\dicing\Desktop\test\fastddsecho off :: vs2022_env.bat call C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\vcvarsall.bat x64 set PATHC:\path\to\cmake\bin;C:\path\to\ninja;%%PATH%% cd /d C:\path\to\workdir %%*4. 使用 vcpkg 编译 Fast DDS4.1 克隆 vcpkgcd C:\fastdds git clone https://github.com/Microsoft/vcpkg.git cd vcpkg .\bootstrap-vcpkg.bat4.2 安装 Fast DDS 及其依赖由于国内 GitHub 访问不稳定建议使用镜像或设置代理# 设置代理可选 http://your-proxy:port http://your-proxy:port # 安装 Fast DDS这会自动安装 fastcdr, foonathan_memory, tinyxml2, openssl 等依赖 cd C:\fastdds\vcpkg .\vcpkg install fastdds:x64-windows # 安装 fasrtcdr如未自动安装 .\vcpkg install fastcdr:x64-windows注意: vcpkg 会自动处理所有依赖。如果网络不好可以多次重试 --recurse。编译完成后头文件在 cpkg\installed\x64-windows\include库和 DLL 在 cpkg\installed\x64-windows\bin。4.3 关键路径项目路径vcpkg 安装目录cpkg\installed\x64-windowsFast DDS 头文件cpkg\installed\x64-windows\includeDLL 目录cpkg\installed\x64-windows\binCMake configcpkg\installed\x64-windows\share\fastdds\fastdds-config.cmake5. 编译 Fast DDS Spy5.1 克隆依赖项目由于国内网络问题如果 GitHub clone 失败可以多次重试set CFLAGS set CXXFLAGS cd C:\fastdds :: 克隆 dev-utils包含 cmake_utils 和 cpp_utils git clone --depth 1 https://github.com/eProsima/dev-utils.git :: 克隆 DDS-Pipeddspipe 相关库 git clone --depth 1 https://github.com/eProsima/DDS-Pipe.git -b 1.x :: 克隆 Fast-DDS-Spy git clone --depth 1 https://github.com/eProsima/Fast-DDS-Spy.git -b 1.x5.2 编译顺序按依赖关系Fast DDS Spy 的依赖链为cmake_utils → cpp_utils → ddspipe_core / ddspipe_participants / ddspipe_yaml → fastddsspy_participants / fastddsspy_yaml → fastddsspy步骤 1: 编译 cmake_utils 和 cpp_utils:: 设置 VS2022 环境 call C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\vcvarsall.bat x64 :: 设置路径 set PATHC:\path\to\cmake\bin;C:\path\to\ninja;%PATH% set CMAKE_PREFIX_PATHC:\fastdds\vcpkg\installed\x64-windows :: 编译 dev-utils cmake -G Ninja -S dev-utils -B build\dev-utils ^ -DCMAKE_BUILD_TYPERelease ^ -DCMAKE_INSTALL_PREFIXinstall ^ -DCMAKE_PREFIX_PATH%CMAKE_PREFIX_PATH% cmake --build build\dev-utils --parallel cmake --install build\dev-utils步骤 2: 编译 DDS-Pipecmake -G Ninja -S DDS-Pipe -B build\ddspipe ^ -DCMAKE_BUILD_TYPERelease ^ -DCMAKE_INSTALL_PREFIXinstall ^ -DCMAKE_PREFIX_PATH%CMAKE_PREFIX_PATH% cmake --build build\ddspipe --parallel cmake --install build\ddspipe步骤 3: 编译 Fast-DDS-Spycmake -G Ninja -S Fast-DDS-Spy -B build\fastddsspy ^ -DCMAKE_BUILD_TYPERelease ^ -DCMAKE_INSTALL_PREFIXinstall ^ -DCMAKE_PREFIX_PATH%CMAKE_PREFIX_PATH% cmake --build build\fastddsspy --parallel cmake --install build\fastddsspy编译完成后 astddsspy.exe 位于 install\bin\ 目录下。5.3 Fast DDS Spy 的使用# 查看帮助 fastddsspy.exe --help # 查看版本 fastddsspy.exe --version # 监控域 0默认 fastddsspy.exe # 监控指定域 fastddsspy.exe --domain 1 # 使用配置文件 fastddsspy.exe -c my_config.yamlYAML 配置示例FASTDDSSPY_CONFIGURATION.yamlspy:domain:0discovery-time:5output-file:spy_output.txt6. 编译 Shapes Demo6.1 克隆 Shapes Democd C:\fastdds git clone https://github.com/eProsima/ShapesDemo.git6.2 安装 Qt6Shapes Demo 需要Qt 6.8.3Core、Gui、Widgets 模块。推荐从清华镜像下载源码编译方法 A: 从源码编译 Qt6 qtbase由于 Qt 官方不再提供 Windows 预编译包的直接下载需要从源码编译:: 下载 Qt 6.8.3 源码清华镜像速度快 curl -L -o qtbase-6.8.3.zip ^ https://mirrors.tuna.tsinghua.edu.cn/qt/archive/qt/6.8/6.8.3/submodules/qtbase-everywhere-src-6.8.3.zip :: 解压 tar -xf qtbase-6.8.3.zip -C qt6编译 Qt6最小化配置仅 Core/Gui/Widgets耗时约 7 分钟cmake -G Ninja -S qt6\qtbase-everywhere-src-6.8.3 -B qt6\build ^ -DCMAKE_BUILD_TYPERelease ^ -DCMAKE_INSTALL_PREFIXinstall ^ -DFEATURE_dbusOFF ^ -DFEATURE_sqlOFF ^ -DFEATURE_testlibOFF ^ -DFEATURE_concurrentOFF ^ -DBUILD_SHARED_LIBSON cmake --build qt6\build --parallel cmake --install qt6\build --prefix install方法 B: 使用 Qt Online Installer图形界面从 download.qt.io 下载安装器选择 Qt 6.8.3 → MSVC 2022 64-bit 组件安装。6.3 编译 Shapes Demoset CMAKE_PREFIX_PATHC:\fastdds\install;C:\fastdds\vcpkg\installed\x64-windows cmake -G Ninja -S ShapesDemo -B build\shapes_demo ^ -DCMAKE_BUILD_TYPERelease ^ -DCMAKE_PREFIX_PATH%CMAKE_PREFIX_PATH% cmake --build build\shapes_demo --parallel6.4 运行 Shapes Demo编译完成后ShapesDemo.exe 位于 uild\shapes_demo\ 目录。要运行 Shapes Demo需要确保 DLL 依赖在同一目录详见下一节。7. 创建独立运行目录为了使程序脱离开发环境独立运行需要将所有依赖的 DLL 收集到同一目录。7.1 DLL 依赖清单Shapes Demo 的依赖 DLLDLL来源路径astdds-3.6.dllcpkg\installed\x64-windows\binastcdr-2.3.dllcpkg\installed\x64-windows\binoonathan_memory-0.7.4.dllcpkg\installed\x64-windows\bininyxml2.dllcpkg\installed\x64-windows\binlibssl-3-x64.dllcpkg\installed\x64-windows\binlibcrypto-3-x64.dllcpkg\installed\x64-windows\binQt6Core.dllinstall\binQt6Gui.dllinstall\binQt6Widgets.dllinstall\binQt6Network.dllinstall\binQt6OpenGL.dllinstall\binQt6Xml.dllinstall\binplatforms/qwindows.dllqt6\build\plugins\platformsstyles/qmodernwindowsstyle.dllqt6\build\plugins\stylesimageformats/qjpeg.dllqt6\build\plugins\imageformats其他系统 DLL 如 MSVCP140.dll、VCRUNTIME140.dll 需安装 VC RedistributableFast DDS Spy 的额外依赖 DLL除上述 Fast DDS 相关的 DLL 外还需要DLL来源路径cpp_utils-1.5.dllinstall\binddspipe_core-1.5.dllinstall\binddspipe_participants-1.5.dllinstall\binddspipe_yaml-1.5.dllinstall\binastddsspy_participants-1.5.dllinstall\binastddsspy_yaml-1.5.dllinstall\binyaml-cpp.dllinstall\binQt6PrintSupport.dllinstall\bin7.2 为什么需要这些 DLLFast DDS 和 Fast DDS Spy 是动态链接的程序运行时需要加载所有依赖的 DLL。运行目录结构如下ShapesDemo/ ├── ShapesDemo.exe ├── fastdds-3.6.dll ├── fastcdr-2.3.dll ├── foonathan_memory-0.7.4.dll ├── tinyxml2.dll ├── libssl-3-x64.dll ├── libcrypto-3-x64.dll ├── Qt6Core.dll ├── Qt6Gui.dll ├── Qt6Widgets.dll ├── Qt6OpenGL.dll ├── Qt6Xml.dll ├── platforms/ │ └── qwindows.dll ├── styles/ │ └── qmodernwindowsstyle.dll └── imageformats/ ├── qjpeg.dll ├── qgif.dll └── qico.dll⚠️注意: Qt 的 platform 插件必须放在 platforms/ 子目录中否则程序会报 “no Qt platform plugin” 错误。7.3 一键收集脚本 C:\fastdds\dist\ShapesDemo C:\fastdds\vcpkg\installed\x64-windows\bin C:\fastdds\install\bin C:\fastdds\qt6\build\plugins # 创建目录结构 New-Item -ItemType Directory -Force -Path , \platforms, \styles, \imageformats # 复制 exe 和 DLL Copy-Item build\shapes_demo\ShapesDemo.exe Copy-Item \fastdds-3.6.dll, \fastcdr-2.3.dll, \foonathan_memory-0.7.4.dll Copy-Item \tinyxml2.dll, \libssl-3-x64.dll, \libcrypto-3-x64.dll Copy-Item \Qt6*.dll Copy-Item \platforms\qwindows.dll \platforms\ Copy-Item \styles\qmodernwindowsstyle.dll \styles\ Copy-Item \imageformats\*.dll \imageformats\8. 使用指南8.1 运行 Fast DDS SpyFast DDS Spy 是一个命令行工具用于监控 DDS 网络流量# 基本用法 - 启动交互式 CLI 监控域 0 fastddsspy.exe # 监控指定域 fastddsspy.exe --domain 1 # 使用自定义配置 fastddsspy.exe -c my_config.yaml # 设置日志级别 fastddsspy.exe --log-verbosity info在交互式 CLI 中可以实时查看发现的 DomainParticipants发布/订阅的 TopicsTopic 数据内容8.2 运行 Shapes DemoShapes Demo 是一个图形化演示程序ShapesDemo.exe启动后你会看到主窗口可以发布形状Publisher:点击Publish按钮选择形状类型Circle / Square / Triangle选择颜色设置大小和移动方向点击 OK 开始发布订阅形状Subscriber:点击Subscribe按钮选择要订阅的形状/颜色点击 OK 开始接收演示效果:多个 Shapes Demo 实例可以在同一网络/域中通信发布者发送的彩色形状会显示在订阅者的画布上支持过滤Content Filter只订阅特定颜色或形状8.3 验证安装用 Fast DDS Spy 监控 Shapes Demo启动 Shapes Demo启动 Fast DDS Spyash fastddsspy.exe --domain 0Spy 会自动发现 Shapes Demo 创建的 Participant 和 Topics在 Shapes Demo 中发布一个形状Spy 会显示 Topic 数据和通信内容9. 常见问题Q1: 运行时报 “no Qt platform plugin” 错误原因: Qt 找不到平台插件 qwindows.dll。解决: 确保运行目录下有 platforms\qwindows.dll 子目录和文件。Q2: 运行时提示缺少 MSVCP140.dll 或 VCRUNTIME140.dll原因: 缺少 Visual C Redistributable。解决: 安装 VC Redistributable。Q3: GitHub clone 失败原因: 国内网络访问 GitHub 不稳定。解决:多次重试 clone使用代理git config --global http.proxy使用 Gitee 镜像Q4: vcpkg 下载依赖失败解决:powershell .\vcpkg install fastdds:x64-windows --recurseQ5: 编译 Qt6 时报错原因: Qt6 需要完整的 MSVC 环境。解决: 确保在 VS2022 的 x64 命令提示符中运行 cmake。Q6: “fastddsspy.exe 无法启动因为计算机中丢失 api-ms-win-crt-*.dll”原因: 系统缺少 Universal C Runtime。解决: 安装 Windows Update KB2999226 或安装 VC Redistributable。附录: 本机构建目录结构C:\fastdds\ ├── vcpkg\ # vcpkg 包管理器 │ └── installed\x64-windows\ # Fast DDS 和依赖安装目录 │ ├── bin\ # DLL 文件 │ ├── include\ # 头文件 │ ├── lib\ # LIB 导入库 │ └── share\ # CMake config 文件 ├── dev-utils\ # cmake_utils, cpp_utils 源码 ├── DDS-Pipe\ # ddspipe 源码 ├── Fast-DDS-Spy\ # Fast DDS Spy 源码 ├── ShapesDemo\ # Shapes Demo 源码 ├── qt6\ # Qt6 源码和构建目录 │ ├── qtbase-everywhere-src-6.8.3\ # Qt6 源码 │ ├── build\ # Qt6 构建输出 │ └── plugins\ # Qt6 插件 ├── build\ # 所有项目的构建输出 │ ├── dev-utils\ │ ├── ddspipe\ │ ├── fastddsspy\ │ └── shapes_demo\ ├── install\ # 统一安装前缀 │ ├── bin\ # 所有 exe 和 DLL │ ├── include\ # 头文件 │ └── lib\ # 库文件 ├── dist\ # 独立运行目录 │ ├── ShapesDemo\ # Shapes Demo 独立运行包 │ └── fastddsspy\ # Fast DDS Spy 独立运行包 └── downloads\ # 下载的源码包