• 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 无法访问

    1. 修改 hosts 文件
    2. 替换为镜像站:把 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 包

    1. 手动下载 gradle 包,放到 ~/Fast-DDS/src/fastddsgen/thirdparty/idl-parser/gradle/wrapper
    2. 编辑 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
      
    3. 运行 ./gradlew assemble,编译之后的程序在 ~/Fast-DDS-Gen/scripts/fastddsgen 目录
    4. 将该目录添加到 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
    

    image

  • 相关阅读:
    asp.net编程基础
    http://blog.csdn.net/pjw100/article/details/5261582
    英雄无敌3版的仙剑奇侠传
    另类DATAGRID数据编辑修改
    使用INDY组件发送邮件,DEMO程序没有讲到的一些内容.如邮件格式定议
    .net 简单实现MD5
    VB.NET 对于类型的传递按值或者按引用
    Start with Database Connection Pool 连接管理
    ASP页面之间传值
    正则表达式
  • 原文地址:https://www.cnblogs.com/tengzijian/p/15541726.html
Copyright © 2020-2023  润新知