前言
为什么要在 windows下编译 Fast-DDS,无他,单纯的觉得 visual studio 调试代码比 vscode remote 到 ubuntu 调试代码方便。
为什么要用 2.14.3 这个版本,因为公司用的是这个版本。
下载代码
打开powershell,执行以下命令拉取代码,如果 clone 失败,设置一下 git 代理,或者直接网页下载zip包解压到对应目录
E:
git clone https://github.com/eProsima/Fast-DDS.git
cd Fast-DDS
git checkout 2.14.3
git submodule update --init #拉取子模块android,asio,fascdr,tinyxml2
git submodule add https://github.com/foonathan/memory.git thirdparty/foonathan-memory #需要添加一个子模块
编译依赖库
- 编译 foonathan-memory
cd thirdparty/foonathan-memory
mkdir build
cd build
cmake ../ -DFOONATHAN_MEMORY_BUILD_EXAMPLES=OFF -DFOONATHAN_MEMORY_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=E:\Fast-DDS-2.14.3\thirdparty\install
# 使用vs打开sln工程,编译,安装;如果是linux,则使用命令 make && make install
- 编译 fastcdr
cd thirdparty/fastcdr
mkdir build
cd build
cmake ../ -DCMAKE_INSTALL_PREFIX=E:\Fast-DDS-2.14.3\thirdparty\install #如果在ubuntu下因为cmake的版本低导致camke失败,可以直接在源码中修改cmake最低要求版本号
# 使用vs打开sln工程,编译,安装;如果是linux,则使用命令 make && make install
- 编译tinyxml2
cd thirdparty/tinyxml2
mkdir build
cd build
cmake ../ -DCMAKE_INSTALL_PREFIX=E:\Fast-DDS-2.14.3\thirdparty\install
# 使用vs打开sln工程,编译,安装;如果是linux,则使用命令 make && make install
编译Fast-DDS和调试
cd Fast-DDS-2.14.3
mkdir build
cd build
cmake ../ -DCMAKE_PREFIX_PATH="E:\Fast-DDS-2.14.3\thirdparty\asio\asio;E:\Fast-DDS-2.14.3\thirdparty\install" -DNO_TLS=ON -DCOMPILE_EXAMPLES=ON
# 在目录 E:\Fast-DDS-2.14.3\build\examples\cpp\dds\DiscoveryServerExample 打开 DiscoveryServerExample.sln,编译 fastrtps 和 DiscoveryServerExample
# 解决动态库查找问题,即可调试

浙公网安备 33010602011771号