FastDDS 安装过程的坑🕳坑🕳坑🕳坑🕳坑🕳坑🕳
第一次遇到这么坎坷的安装过程,几乎没有一步能顺利走下去,不论选择了哪条路😂
条条大路走不通之 Colcon 方式安装
FastDDS Github 上找到如下安装步骤(Colcon 方式):
pip install -U colcon-common-extensions vcstool
mkdir fastdds_ws
cd fastdds_ws
wget https://raw.githubusercontent.com/eProsima/Fast-DDS/master/fastrtps.repos
mkdir src
vcs import src < fastrtps.repos
🕳 1:raw.githubusercontent.com 无法访问
- 修改 hosts 文件
- 替换为镜像站:把
githubusercontent.com
全部替换成raw.fastgit.org
例如
替换为wget https://raw.githubusercontent.com/eProsima/Fast-DDS/master/fastrtps.repos
wget https://raw.fastgit.org/eProsima/Fast-DDS/master/fastrtps.repos
我还试过 gitee 和 cnpmjs.org 镜像站,仓库不全,有的提示找不到
🕳 2:github 连接速度慢/无法访问
使用镜像站点。
git config --global url."https://gitclone.com/github.com/".insteadOf "https://github.com/"
或者
git config --global url."https://hub.fastgit.org/".insteadOf "https://github.com/"
🕳 3:Command 'vcs' not found
vcs import src < fastrtps.repos
Command 'vcs' not found, did you mean:
...
Try: sudo apt install <deb name>
原因:pip install 可能把 vcs 安装到了 ~/.local/bin
解决办法:修改 PATH
变量
PATH=$PATH:~/.local/bin
搞定!(高兴得太早😂)
🕳 4:colcon 报错
ERROR:colcon.colcon_core.entry_point:Exception loading extension 'colcon_core.environment_variable.defaults': (pyparsing 3.0.5 (/home/zijian/.local/lib/python3.8/site-packages), Requirement.parse('pyparsing<3,>=2.0.2'), {'packaging'})
你厉害,你厉害,我放弃。
条条大路走不通之 Linux 源码方式安装
安装序列化库 CDR
$ git clone https://github.com/eProsima/Fast-CDR.git
$ mkdir Fast-CDR/build && cd Fast-CDR/build
$ cmake ..
$ cmake --build . --target install
如果最后一步提示没有权限,sudo
一下即可
安装 foonathan 分配器
$ git clone https://github.com/eProsima/foonathan_memory_vendor.git
$ cd foonathan_memory_vendor
$ mkdir build && cd build
$ cmake ..
$ cmake --build . --target install
make
过程中还会从 github 下载代码,如有必要,用 sed
命令把 CMake 生成的临时文件 build/foo_mem-ext-prefix/tmp/foo_mem-ext-gitclone.cmake 中 github.com 替换成 hub.fastgit.org
安装 FastDDS
$ git clone https://github.com/eProsima/Fast-DDS.git
$ mkdir Fast-DDS/build && cd Fast-DDS/build
$ cmake ..
$ cmake --build . --target install
安装 Fast DDS Gen(IDL 生成 C++ 代码)
git clone --recursive https://github.com/eProsima/Fast-DDS-Gen.git
cd Fast-DDS-Gen
gradle assemble
上述步骤中存在诸多 gradle
的坑:
🕳 5:系统 gradle 版本和 FastDDS 的不匹配
使用文件夹下 ./gradlew assemble
,自动下载和当前 FastDDS 匹配的 gradle 版本
🕳 6:gradlew 可能因代理问题无法下载 gradle 包
- 手动下载 gradle 包,放到 ~/Fast-DDS/src/fastddsgen/thirdparty/idl-parser/gradle/wrapper
- 编辑 fastddsgen/thirdparty/idl-parser/gradle/wrapper/gradle-wrapper.properties,删除 distributionUrl 字段的
https://services.gradle.org/distributions/distributionUrl=https\://services.gradle.org/distributions/gradle-2.2-all.zip
- 运行
./gradlew assemble
,编译之后的程序在 ~/Fast-DDS-Gen/scripts/fastddsgen 目录 - 将该目录添加到
PATH
路径PATH=$PATH:~/Fast-DDS-Gen/scripts
编译示例代码
🕳 7:undefined reference to symbol 'pthread_create@@GLIBC_2.2.5'
~/Fast-DDS/examples/build$ make
[ 3%] Built target DeadlineQoSExample
[ 5%] Built target DisablePositiveACKs
[ 7%] Built target OwnershipStrengthQoSExample
[ 7%] Linking CXX executable DynamicHelloWorldExample
/usr/bin/ld: CMakeFiles/DynamicHelloWorldExample.dir/HelloWorldPublisher.cpp.o: undefined reference to symbol 'pthread_create@@GLIBC_2.2.5'
/usr/bin/ld: /lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [C++/DynamicHelloWorldExample/CMakeFiles/DynamicHelloWorldExample.dir/build.make:116: C++/DynamicHelloWorldExample/DynamicHelloWorldExample] Error 1
make[1]: *** [CMakeFiles/Makefile2:1268: C++/DynamicHelloWorldExample/CMakeFiles/DynamicHelloWorldExample.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
在 Fast-DDS/examples/CMakeLists.txt 中添加一行
set(CMAKE_CXX_FLAGS "${CAMKE_CXX_FLAGS} -std=c++11 -pthread")
终于编译成功!开启两个终端,运行下 HelloWorldExample,一个作为 publisher,另一个作为 subscriber。
Fast-DDS/examples/build/C++/HelloWorldExample ./HelloWorldExample publisher
Fast-DDS/examples/build/C++/HelloWorldExample ./HelloWorldExample subscriber
本文作者:Zijian/TENG(微信公众号:好记性如烂笔头),转载请注明原文链接:https://www.cnblogs.com/tengzijian/p/15541726.html
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析