从零开始跑起来 cyclonedds 的 helloworld 项目
tags: 编程
@
从零开始跑起来 cyclonedds 的 helloworld 项目
全程基于已下载的两个源码包: cyclonedds-11.0.1.tar.gz(C 核心库)cyclonedds-cxx-11.0.1.tar.gz(C++ 绑定库)
准备工作
- 把两个压缩包放到用户主目录(
~/) - 安装基础依赖
# Debian
sudo apt update sudo apt install build-essential cmake
# OpenEuler
sudo dnf install gcc gcc-c++ cmake make
编译安装 CycloneDDS(C 核心库,必须第一步)
# 解压
tar -zxvf cyclonedds-11.0.1.tar.gz
cd cyclonedds-11.0.1
# 编译
mkdir build && cd build
cmake ..
make -j4
# 安装到系统
sudo make install
编译安装 CycloneDDS-CXX(C++ 库)
cd ~ tar -zxvf cyclonedds-cxx-11.0.1.tar.gz cd cyclonedds-cxx-11.0.1
# 编译
mkdir build && cd build
cmake ..
make -j4
# 安装到系统
sudo make install
编译 Helloworld 示例
# 进入helloworld示例目录
cd ~/cyclonedds-cxx-11.0.1/examples/helloworld
# 创建编译目录并进入
mkdir build && cd build
# 编译
cmake ..
make
运行示例
终端 1(发布者)
cd ~/cyclonedds-cxx-11.0.1/examples/helloworld/build
./HelloworldPublisher
终端 2(订阅者,需新开终端)
cd ~/cyclonedds-cxx-11.0.1/examples/helloworld/build
./HelloworldSubscriber
订阅者终端能接收并显示发布者发送的消息,即完成所有操作。