FastDDS 从源码安装到Linux FastDDS Linux Installation from Sources

FastDDS Linux installation from sources

在这里插入图片描述

FastDDS是由位于西班牙马德里的eProsima公司推出的免费开源DDS中间件解决方案,并提供付费技术支持服务。它的源码基于C++,规范基于OMG DDS 1.4 and the OMG RTPS 2.2。本文的目的是根据官方的安装步骤进行整理,并记录自己在安装过程中遇到的实际问题和解决方法。

官方文档链接:https://fast-dds.docs.eprosima.com/en/latest/
在这个线上文档中除了由对FastDDS基本的介绍,安装的方法,还有丰富的入门指导和实例解释。

FastDDS的安装按系统分有三种:

  • Windows (from Binaries 或Sources)
  • Linux(from Binaries 或Sources)
  • MAC Os (from Sources)

    You can get either a binary distribution of eprosima Fast DDS or compile the library yourself from source.

这里我装的是Linux from Sources。

FastDDS的安装内容主要有三部分:

  • Fast DDS library (必须安装)
    • foonathan_memory_vendor : C++ memory allocator lib
    • fasdcdr: CDR serialization mechanism
    • fastrtps: Fast DDS core lib

    其中安装方式又分为两种,colcon安装或CMake安装。我用的是colcon。

  • Fast DDS Python bindings (可选)

    Fast DDS Python bindings is an extension of Fast DDS which provides access to the Fast DDS API through Python.

  • Fast DDS-Gen (必须安装)
    • Java application generates source code from IDL file。由IDL文件中定义的data type生成代码的脚本工具。在旧版本中脚本工具的名字叫fastrtpsgen,大概在21年后改名叫fastddsgen
1. 安装Fast DDS Library
  1. 链接:https://fast-dds.docs.eprosima.com/en/latest/installation/sources/sources_linux.html#fast-dds-library-installation
  2. 安装依赖项:
sudo apt install cmake g++ python3-pip wget git
sudo apt install libasio-dev libtinyxml2-dev
sudo apt install libssl-dev

libp11 and HSM libs:
//sudo apt install libp11-dev libengine-pkcs11-openssl (可选,只有DDS用到security和PKCS#11 URI时才需要,我没装)
//sudo apt install softhsm2 (可选,我没装,装了libp11-dev才需要)
//sudo usermod -a -G softhsm <user> (可选,我没装,同上)
//sudo apt install libengine-pkcs11-openssl (同上)
//p11-kit list-modules(同上)
//openssl engine pkcs11 -t(同上)

Gtest: 可选,C++单元测试库,我还没装
//git clone https://github.com/google/googletest src/googletest-distribution

  1. 使用Colcon 安装Fast DDS lib

3.1 安装colcon, vcstool:

pip3 install -U colcon-common-extensions vcstool

vcstool安装不成功造成命令 vcs不能使用的话,可以尝试reboot之后重新安装,也可以尝试将-U 替换成–user安装
3.2 把repos下载下来,为后面的vcs import做准备:

mkdir ~/Fast-DDS
cd ~/Fast-DDS
wget https://raw.githubusercontent.com/eProsima/Fast-DDS/master/fastrtps.repos

注意:以上命令运行之后只有fastrtps.repos一个文件,下图中的其余文件时后面build生成的

这里可能会碰到连接失败的错:

Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|::|:443... failed: Connection refused.

参考了:https://blog.csdn.net/laoxuan2011/article/details/106177126/?utm_term=https://raw.githubusercontent.com/&utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2allsobaiduweb~default-0-106177126&spm=3001.4430

需要修改/etc/hosts,在末尾添加一行:
151.101.76.133(此IP是通过本机IP查询的值) raw.githubusercontent.com


3.3 下一步,把repos的内容导入到src文件夹:

mkdir src
vcs import src < fastrtps.repos

3.4 build packages:

colcon build

这里可能遇到CMake版本问题,因为colcon是依赖CMake build的。我用的ubuntu 18.04,用第一步依赖项安装的时候,cmake版本最高都没有达到colcon要求的版本。

CMake 3.8(具体3点几没记住) or higher is required. 

按照 https://www.cnblogs.com/jsdy/p/12689470.html 的方法卸载重新安装了3.16的CMake。

但是这里安装的路径到了/usr/local/bin/cmake,而不是colcon默认使用的/usr/bin/cmake路径。所以后面又碰到了这个错:

make: /usr/bin/cmake: Command not found

通过以下命令把两个路径关联了:

sudo ln -s /usr/local/bin/cmake /usr/bin/cmake

或者可以找方法,在安装的时候就指定路径到/usr/bin/cmake。

  1. 准备环境变量

4.1 每次新打开一个shell的时候可以运行source命令,设置局部环境变量:

source ~/Fast-DDS/install/setup.bash

4.2 或者设置永久环境变量:

echo 'source ~/Fast-DDS/install/setup.bash' >> ~/.bashrc

这样就可以使用fastdds命令了。


2. 安装Fast DDS-Gen
  1. 链接:https://fast-dds.docs.eprosima.com/en/latest/installation/sources/sources_linux.html#fast-dds-gen-installation

  2. 安装Java JDK:

    sudo apt install openjdk-8-jdk
    
  3. 安装Gradle:

    这一步不用装。Gradle是一个开源自动化build工具。我从Gradle下了安装包安装完发现不能用,看起来是版本问题。官方最新版是7.4.2。Fast DDS-gen用6.4就可以。后面会说到免安装的方法。

  4. 从git clone dds-gen的包:

    这一步按照官网说法,前面用colcon安装就不用git clone:

    If already installed FastDDS with colcon, you may skip the git clone command; fastddsgen can be found under the src directory of FastDDS colcon workspace.

    但是我的Fast-DDS/src/fastddsgen下面几乎是空的只有一个thirdparty文件夹,并不能成功build,所以我还是git clone了一下:

    执行git clone:

    cd ~
    git clone --recursive https://github.com/eProsima/Fast-DDS-Gen.git
    
  5. 执行gradle编译

    cd Fast-DDS-Gen
    //gradle assemble   这一步是安装了gradle的情况下执行的。我没用,用了报错。
    ./gradlew assemble  这里我用免安装的方法编译了。就是下面说的executable script
    

    运行/gradlew assemble 之后才能生成如下图的share文件夹,否则调用fastddsgen工具时会报如下图的错误。
    在这里插入图片描述
    在这里插入图片描述

    If errors occur during compilation or you do not wish to install gradle, an executable script is included which will download a gradle temporarily for the compilation step.

  6. 把fastddsgen的命令放到环境变量

    cd /etc
    sudo gedit profile
    

    在profile末尾加入:

    export PATH="$PATH:~/Fast-DDS-Gen/scripts"
    

    重新登录
    可以看到fastddsgen的命令加进来了:

  • 3
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
您好!要在Linux上进行源码安装,您可以按照以下步骤进行操作: 1. 获取源代码:您需要找到您想要安装的软件的源代码。通常,您可以在软件的官方网站或代码托管平台(如GitHub)上找到源代码。 2. 安装必要的依赖项:在编译和安装软件之前,您需要确保系统上安装了所需的依赖项。这些依赖项可能包括编译器、开发库和其他工具。您可以使用软件包管理器来安装这些依赖项,例如在Ubuntu上使用apt-get命令: ``` sudo apt-get update sudo apt-get install build-essential ``` 3. 解压源代码:将下载的源代码解压到一个目录中。您可以使用tar命令来解压tar.gz或tar.bz2文件,例如: ``` tar -xf source_code.tar.gz ``` 4. 进入源代码目录:使用cd命令进入解压后的源代码目录: ``` cd source_code ``` 5. 配置编译选项:运行适当的配置脚本来配置软件的编译选项。这个脚本通常是`configure`或`CMakeLists.txt`。您可以使用以下命令进行配置: ``` ./configure ``` 6. 编译源代码:运行make命令来编译源代码: ``` make ``` 7. 安装软件:运行make install命令来安装编译后的软件: ``` sudo make install ``` 8. 完成安装:完成上述步骤后,您的软件应该已成功安装在您的Linux系统上。 请注意,不同的软件可能有不同的安装步骤和要求。确保在安装软件之前查阅相关的文档或官方指南以获取更详细的说明。 希望这可以帮助您进行源码安装!如果您有任何其他问题,请随时提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值