【FastRTPS】ubuntu16.04/ubuntu20.04下1.9版本安装
说明:本过程同样适用于ubuntu20.04下FastDDS2.0.1安装。
1. 下载1.9源码:
$ git clone https://github.com/eProsima/Fast-RTPS.git --branch v1.9.0
2.安装asio和TinyXML
$ sudo apt install libasio-dev libtinyxml2-dev
3. 安装foonathan_memory:
$ git clone https://github.com/foonathan/memory.git $ cd memory $ git submodule update --init --recursive $ mkdir build && cd build $ cmake -DCMAKE_CXX_FLAGS=-fPIC -DFOONATHAN_MEMORY_BUILD_EXAMPLES=OFF -DFOONATHAN_MEMORY_BUILD_TESTS=OFF .. #不指定目录安装 $ sudo cmake --build . --target install #指定目录安装 $ sudo cmake --build . --target install DESTDIR=[安装目录]
DESTDIR为可选项,用于指定安装目录。
memory、FastCDR、FastRTPS安装要么都指定安装目录,要么都不指定(默认安装到/usr/local目录下)。
4.安装FastCDR
$ git clone https://github.com/eProsima/Fast-CDR.git $ mkdir Fast-CDR/build && cd Fast-CDR/build $ cmake .. #不指定目录安装 $ sudo cmake --build . --target install #指定目录安装 $ sudo cmake --build . --target install DESTDIR=[安装目录]
5.安装Fast-RTPS-1.9:
进入Fast-RTPS/build目录执行:
#不指定目录安装 $ cmake .. $ cmake --build . --target install #指定目录安装 $ cmake -DCMAKE_PREFIX_PATH=[memory安装目录]/usr/local .. $ cmake -DCMAKE_PREFIX_PATH=[fastCDR安装目录]/usr/local .. $ cmake --build . --target install DESTDIR=[FastRTPS安装目录]
cmake编译选项说明:
-DBUILD_JAVA --用于生成fastrtpsgen,需提前安装JAVA
-DCOMPILE_EXAMPLES --用于编译examples目录下的例子程序
-DPERFORMANCE_TESTS --用于编译test/performance下的性能测试程序
-DTHIRDPARTY --用于自动下载编译第三方依赖库,包括asio/tinyxml等,如果在ros下使用FastRTPS需要将此选项OFF掉,因为ros也依赖了tinyxml库,会导致库不一致的问题。
-DCMAKE_PREFIX_PATH --搜索依赖库的路径
如果指定了安装目录,需要配置环境变量(不指定时会安装到/usr/local下):
export FASTRTPS_ROOT=[FastRTPS安装目录]/usr/local/ export PATH=$FASTRTPS_ROOT/bin:$PATH export LD_LIBRARY_PATH=$FASTRTPS_ROOT/lib:$LD_LIBRARY_PATH export LIBRARY_PATH=$FASTRTPS_ROOT/lib:$LIBRARY_PATH export C_INCLUDE_PATH=$FASTRTPS_ROOT/include:$C_INCLUDE_PATH export CPLUS_INCLUDE_PATH=$FASTRTPS_ROOT/include:$CPLUS_INCLUDE_PATH
