1.安装PERL
使用以下安装脚本:
sh <(curl -q https://platform.activestate.com/dl/cli/install.sh) --activate-default ActiveState/Perl-5.32
若没有CURL 则安装:
sudo apt install curl
sudo apt install perl
2.设置环境变量
设置相关环境变量/etc/profile
在/etc/profile文件尾添加如下环境变量,重启生效
(之前有博客说在.bashrc里添加环境变量,我在编译的时候,总是报"找不到目录",以上红色文字部分才解决了这个问题。)
# ACE+TAO+DDS Environment
export ACE_ROOT=/home/jamie/DevOpenDDS/ACE_wrappers
export TAO_ROOT=$ACE_ROOT/TAO
export DDS_ROOT=/home/jamie/DevOpenDDS/OpenDDS
export PATH=$ACE_ROOT/bin:$DDS_ROOT/bin:$PATH
export LD_LIBRARY_PATH=$ACE_ROOT/lib:$DDS_ROOT/lib:$LD_LIBRARY_PATH
————————————————
版权声明:本文为CSDN博主「Jamie.T」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/jam12315/article/details/113676146
3.编译
3.1 设置config.h
新建$ACE_ROOT/ace/config.h,文件内容为
#include “ace/config-linux.h”
3.2 设置/新建 platform_macros.GNU
新建$ACE_ROOT/include/makeinclude/platform_macros.GNU, 内容如下:
include $(ACE_ROOT)/include/makeinclude/platform_linux.GNU
3.2 安装make
若安装过,请跳过
sudo apt install make
ubuntu make时候提示g++: Command not found
解决方法:
sudo apt-get install build-essential
3.3 编译
配置完以上文件之后,可以进行编译:
编译次序为: ACE -> TAO -> OpenDDS
ACE编译
cd $ACE_ROOT
make clean
make
TAO编译
cd $TAO_ROOT
make clean
make
OpenDDS编译
$ cd $DDS_ROOT
$ ./configure
$ make clean
$ make
OpenDDS编译完成之后,所有的编译过程结束。
3.4 QOS库
qos库要单独编译一下
# 1. xerces-c-3.2.3编译
mkdir build
cd build
cmake ..
make
make install
注意:库编译时,用CMAKE,将编译器选项中的C++14屏蔽掉,不然后面可以会引起模板实例化失败的问题,如get_type_name()报段错误
# 2. 编译ACE_XML_Utils库
cd $ACE_ROOT/ace/XML_Utils
perl $ACE_ROOT/MPC/mwc.pl -type make -features xerces=1
make
错误:
/usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
旧的GCC编译时,若提示有错误,可能需要加上这个 -std=c++11
解决办法,在$ACE_ROOT/ace/XML_Utils下找到 MAKEFILE.ACE_XML_Utils,改为如下所示,增加了C++11的支持
COMPILE.cc = $(CXX) $(CCFLAGS) $(CPPFLAGS) -c -std=c++11
注意:库编译时,不要单独开c++11等新功能,可能不支持,引起错误,尤其是低版本的GCC
# 3. 编译OpenDDS_QOS_XML_XSC_Handlerd库
cd $DDS_ROOT/dds/DCPS/QOS_XML_Handler
perl $ACE_ROOT/MPC/mwc.pl -type make -features xerces=1
#修改MAKEFILE,去掉Makefile.OpenDDS_XML_QOS_XSC_Generation,这个不编译
make
4.测试
可以用python脚本来代替一些SHELL,减少学习量
import os
from multiprocessing import Process
#./DCPSInfoRepo -ORBDebugLevel 4 -ORBLogFile DCPSInfoRepo.log -o repo.ior -ORBListenEndpoints iiop://192.168.101.67:12345
#os.system("sleep 2")
#os.system("./test -ORBDebugLevel 4 -ORBLogFile sub.log ")
#os.system("./DCPSInfoRepo -ORBDebugLevel 4 -ORBLogFile pub.log")
def run_proc(name):
print("Run child process %s (%s)..." % (name, os.getpid()))
if name=="server":
os.system("./DCPSInfoRepo -ORBDebugLevel 4 -ORBLogFile DCPSInfoRepo.log -o repo.ior")
elif name=="pub":
os.system("sleep 2")
os.system("./test -ORBDebugLevel 4 -ORBLogFile pub.log -r pub")
elif name=="sub":
os.system("sleep 2")
os.system("./test -ORBDebugLevel 4 -ORBLogFile sub.log -r sub")
if __name__=='__main__':
print ('Parent process %s.' % os.getpid())
p = Process(target=run_proc, args=('server',))
print ('Process will start.')
p.start()
p1 = Process(target=run_proc, args=('sub',))
print ('Process sub start.')
p1.start()
p2 = Process(target=run_proc, args=('pub',))
print( 'Process pub start.')
p2.start()
5.问题
如果出现以下问题,服务连接不上:
(2831|140737304000256) EXCEPTION, ERROR: InfoRepoDiscovery::get_dcps_info: failed to resolve ior -
system exception, ID 'IDL:omg.org/CORBA/TRANSIENT:1.0'
OMG minor code (2), described as 'No usable profile in IOR.', completed = NO
(2831|140737304000256) ERROR: DomainParticipantImpl::enable, add_domain_participant returned invalid id.
(2831|140737304000256) ERROR: DomainParticipantFactoryImpl::create_participant, unable to enable DomainParticipant.
可以修改/etc/hosts文件,使用本机IP,去掉本机IP以外的IP,包括127.0.0.1