OpenDDS学习笔记(4):OpenDDS在Linux环境编译

文章目录

  • 一、编译前准备
    • 1.1 环境
    • 1.2 下载ACE+TAO与OpenDDS
    • 1.3 解压安装ACE+TAO与OpenDDS
    • 1.4 设置相关环境变量
  • 二、编译
    • 2.1 设置config.h
    • 2.2 设置Platform_macros.GNU
    • 2.3 编译
    • 2.4 运行测试脚本
  • 三、参考来源


一、编译前准备

1.1 环境

  • Linux:Ubuntu 16.04LTS
  • Perl:V5.22.1
  • Make:GNU Make V4.1
  • gcc:V5.4.0

1.2 下载ACE+TAO与OpenDDS

ACE+TAO下载地址:http://download.dre.vanderbilt.edu/
OpenDDS下载地址:http://download.ociweb.com/OpenDDS/

下载时注意:

  • ACE+TAO下载选择FULL版本。
    FULL版本:包含所有GNU make预生成makefile的源代码;
    Sources only版本:仅包含源代码,需要使用MPC生成makefile
  • Linux下选择*.tar.gz格式,Windows下选择*.zip格式。

1.3 解压安装ACE+TAO与OpenDDS

将ACE+TAO与OpenDDS解压至/opt目录下

sudo tar -zxvf ACE+TAO-6.5.5.tar.gz -C /opt
sudo tar -zxvf OpenDDS-3.13.2.tar.gz -C /opt

解压完毕后,在/opt目录下已存在ACE_wrappersOpenDDS-3.13.2两个文件夹,修改其权限
(不修改权限会在编译时出现Permission denied的情况)

cd /opt
sudo chmod 777 -R ACE_wrappers/
sudo chmod 777 -R OpenDDS-3.13.2/

1.4 设置相关环境变量

/etc/profile文件尾添加如下环境变量,重启生效

# ACE+TAO+DDS Environment
export ACE_ROOT=/opt/ACE_wrappers
export TAO_ROOT=$ACE_ROOT/TAO
export DDS_ROOT=/opt/OpenDDS-3.13.2
export PATH=$ACE_ROOT/bin:$DDS_ROOT/bin:$PATH
export LD_LIBRARY_PATH=$ACE_ROOT/lib:$DDS_ROOT/lib:$LD_LIBRARY_PATH

二、编译

2.1 设置config.h

新建$ACE_ROOT/ace/config.h,文件内容为

#include “ace/config-linux.h”

2.2 设置Platform_macros.GNU

新建$ACE_ROOT/include/makeinclude/platform_macros.GNU,文件内容为

include $(ACE_ROOT)/include/makeinclude/platform_linux.GNU

2.3 编译

编译顺序为:ACE -> TAO -> DDS,编译时间长。

  • ACE编译
cd $ACE_ROOT
make clean
make
  • TAO编译
cd $TAO_ROOT
make clean
make
  • DDS编译
cd $TAO_ROOT
./configure
make clean
make

2.4 运行测试脚本

编译完成后,运行测试脚本测试OpenDDS环境是否搭建成功。
$DDS_ROOT/examples/DCPS/Messenger_Imr目录,运行run_test.pl

cd $DDS_ROOT/example/DCPS/Messenger_Imr
perl ./run_test.pl

结果如下

>>> /opt/ACE_wrappers/TAO/orbsvcs/ImplRepo_Service/tao_imr_locator -o imr.ior  -orbendpoint iiop://:10098
>>> /opt/ACE_wrappers/TAO/orbsvcs/ImplRepo_Service/tao_imr_activator -o activator.ior -ORBInitRef ImplRepoService=file://imr.ior  -orbendpoint iiop://:10066
>>> /opt/OpenDDS-3.13.2/bin/DCPSInfoRepo  -NOBITS -o repo.ior  -ORBuseimr 1 -ORBInitRef ImplRepoService=file://imr.ior
>>> /opt/ACE_wrappers/bin/tao_imr -ORBInitRef ImplRepoService=file://imr.ior shutdown InfoRepo
Successfully shut down server <InfoRepo>
>>> /opt/ACE_wrappers/bin/tao_imr -ORBInitRef ImplRepoService=file://imr.ior update InfoRepo -l Fan-Lenovo -c "/opt/OpenDDS-3.13.2/bin/./DCPSInfoRepo  -NOBITS -o repo.ior  -ORBuseimr 1 -ORBInitRef ImplRepoService=file://imr.ior"
(486|140412808431424) ImR: Successfully registered <InfoRepo>
>>> /opt/ACE_wrappers/bin/tao_imr -ORBInitRef ImplRepoService=file://imr.ior list -v
Server <InfoRepo>
  Activator: Fan-Lenovo
  Command Line: /opt/OpenDDS-3.13.2/bin/./DCPSInfoRepo  -NOBITS -o repo.ior  -ORBuseimr 1 -ORBInitRef ImplRepoService=file://imr.ior
  Working Directory: 
  Activation Mode: NORMAL
  Number of retries: 0
  Not currently running

/opt/OpenDDS-3.13.2/examples/DCPS/Messenger_Imr/publisher   -DCPSConfigFile pub.ini -orbendpoint iiop://:10109
/opt/OpenDDS-3.13.2/examples/DCPS/Messenger_Imr/subscriber   -DCPSConfigFile sub.ini
(488|139645218817856) Writer::start 
(488|139645109663488) Writer::svc begins.
DataReaderListenerImpl::on_subscription_matched
(488|139645109663488) 14:52:25.926322 Writer::svc starting to write.
DataReaderListenerImpl::on_liveliness_changed
Message: subject    = Review
         subject_id = 99
         from       = Comic Book Guy
         count      = 0
         text       = Worst. Movie. Ever.
SampleInfo.sample_rank = 0
Message: subject    = Review
         subject_id = 99
         from       = Comic Book Guy
         count      = 1
         text       = Worst. Movie. Ever.
SampleInfo.sample_rank = 0
Message: subject    = Review
         subject_id = 99
         from       = Comic Book Guy
         count      = 2
         text       = Worst. Movie. Ever.
SampleInfo.sample_rank = 0
Message: subject    = Review
         subject_id = 99
         from       = Comic Book Guy
         count      = 3
         text       = Worst. Movie. Ever.
SampleInfo.sample_rank = 0
Message: subject    = Review
         subject_id = 99
         from       = Comic Book Guy
         count      = 4
         text       = Worst. Movie. Ever.
SampleInfo.sample_rank = 0
Message: subject    = Review
         subject_id = 99
         from       = Comic Book Guy
         count      = 5
         text       = Worst. Movie. Ever.
SampleInfo.sample_rank = 0
Message: subject    = Review
         subject_id = 99
         from       = Comic Book Guy
         count      = 6
         text       = Worst. Movie. Ever.
SampleInfo.sample_rank = 0
Message: subject    = Review
         subject_id = 99
         from       = Comic Book Guy
         count      = 7
         text       = Worst. Movie. Ever.
SampleInfo.sample_rank = 0
Message: subject    = Review
         subject_id = 99
         from       = Comic Book Guy
         count      = 8
         text       = Worst. Movie. Ever.
SampleInfo.sample_rank = 0
Message: subject    = Review
         subject_id = 99
         from       = Comic Book Guy
         count      = 9
         text       = Worst. Movie. Ever.
SampleInfo.sample_rank = 0
DataReaderListenerImpl::on_liveliness_changed
DataReaderListenerImpl::on_subscription_matched
(488|139645109663488) Writer::svc finished.
(488|139645218817856) Writer::end 
>>> /opt/ACE_wrappers/bin/tao_imr -ORBInitRef ImplRepoService=file://imr.ior shutdown InfoRepo
Successfully shut down server <InfoRepo>
test PASSED.

运行结果显示test PASSED,测试成功。


三、参考来源

【1】http://blog.sina.com.cn/s/blog_6f83fdb40101i62i.html
【2】https://blog.csdn.net/wyc12306/article/details/79665454
【3】https://www.cnblogs.com/joeywang/p/3719815.html

你可能感兴趣的:(OpenDDS)