实时CORBA平台TAO的安装和使用

 

实时CORBA平台TAO的安装和使用

这里以ACE-5.4+TAO-1.4+CIAO-0.4.tar.gz为例。

一.     Win32+VC6.0下编译和安装ACE和TAO
将网上下载的TAO软件包解压缩到某个目录(本文为C:\),该目录下会有ACE_wrappers目录。
请按照以下步骤来执行:
1. 新建两个环境变量:
ACE_ROOT=C:\ACE_wrappers
TAO_ROOT=C:\ACE_wrappers\tao

为系统变量PATH加上C:\ACE_wrappers\bin
2. 在ACE_ROOT\ace(即C:\ACE_wrappers\ace)目录下用VC建立一个空的头文件config.h,里面包含一句:#include "ace/config-win32.h"
以说明是要在win32平台下进行编译。

3.用VC打开TAO和ACE的工程文件:ACE_ROOT\tao\taoace.dsw,开始编译ACE
和TAO. 注意ACE和TAO有Debug和Release两个版本. 你在开发自己的程序时,
如果是Debug版的程序, 必须链接Debug版的TAO库, 如果是Release版的程序,
必须链接Release版的TAO库.

3.在编译taoace.dsw之前需要先安装OpenSSL,而OpenSSL安装前需安装脚本语言Perl

安装好后会在C盘下生成文件夹perl

Perl安装后,开始安装OpenSSL

(1) Firstly you should run Configure:

         > perl Configure VC-WIN32

      (2) Next you need to build the Makefiles and optionally the assembly language

          files:

_If you don't want to use the assembly language files at all then run:

   Openssl-0.9.6> ms\do_ms

(3)Now to install

   在DOS环境下

   Follow the steps below:

         $ md c:\openssl

         $ md c:\openssl\bin

         $ md c:\openssl\lib

         $ md c:\openssl\include

         $ md c:\openssl\include\openssl

         $ copy /b inc32\*               c:\openssl\include\openssl

         $ copy /b out32dll\ssleay32.lib c:\openssl\lib

         $ copy /b out32dll\libeay32.lib c:\openssl\lib

         $ copy /b out32dll\ssleay32.dll c:\openssl\bin

         $ copy /b out32dll\libeay32.dll c:\openssl\bin

         $ copy /b out32dll\openssl.exe  c:\openssl\bin

 

         详情见openssl-0.9.6文件夹下的文本文件INSTALL

安装好后会在C盘下生成文件夹openssl

 4. 打开VC环境下 Project>setting>设置 选择Win32 Debug

5.打开VC环境下 Tools>Options>Directories
加入以下内容:
Executable File:
C:\ACE_wrappers\bin

C:\ACE_WRAPPERS\TAO\TAO

Include File:
C:\ACE_wrappers\
C:\ACE_wrappers\TAO

C:\ACE_WRAPPERS\TAO\tao
C:\ACE_wrappers\TAO\orbsvcs

C:\openssl\include

C:\ACE_wrappers\bin


Library Files:
C:\ACE_wrappers\ace
C:\ACE_wrappers\TAO\tao
C:\ACE_wrappers\TAO\orbsvcs\orbsvcs

C:\openssl\lib

C:\ACE_wrappers\bin

C:\ACE_wrappers\usrlib(见后面说明)


Source Files:
C:\ACE_wrappers\ace
C:\ACE_wrappers\TAO\tao
C:\ACE_wrappers\TAO\orbsvcs\orbsvcs

C:\ACE_wrappers\bin

   

     6.taoace.dsw

VC环境下 组建>批组建,选择你需要的工程配置(所有的带Win32 Debug的文件),然后“全部重建”,此过程可能持续二至四个钟头       

产生的.lib文件位于C:\ACE_wrappers\ace\下
 产生的.dll文件位于C:\ACE_wrappers\bin\下


   

 

VC下的TAO的使用(以书上的简单程序为例)

本程序的主要目的是使客户机获取格林威治当前时间(详细程序见书)

1.C:\下新建CORBA文件夹,文件夹下新建三个文件夹:time、Server、Client

2.首先编写IDL的定义。在VC环境下新建一个C++ Sourse File文件,编写IDL的定义,保存为time.idl(time 文件夹下)

3.修改配置

project-->settings…-->C/C++ àCategory:Code Generation àUse run-time library设置为“Debug Multithreaded DLL”

project-->settings…-->C/C++ àCategory:Preprocessor àAdditional include directories中添加C:\ACE_wrappers

project-->settings…àLink àCategory:Input àObject/library modules:中添加aced.lib taod.lib,并在下面的Additional library path里面添加路径C:\ACE_wrappers\ace

(注:编译时发现还需要加很多类库,所以最好将ACE_wrappers下的所有.lib文件放到一个文件夹下,将每个.lib都加到Object/library modules下,然后再将文件夹的路径加到Library Files:中,见前文,这样就能保证编译时所需的所有库都包含在其中了)

4.编译IDL。找到IDL编译器tao_idl.exe(一般在ACE_wrappers\bin下)。打开DOS环境

输入C:\ACE_wrappers\bin\tao_idl C:\CORBA\time\time.idl 编译idl。将生成的9个文件分别拷到Server和Client目录下。

 

(The IDL compiler generates 9 files from each .idl file. The file names are obtained by taking the IDLbasename and appending the following suffixes (see the list of TAO's IDL compileroptions on how to get different suffixes for these files:)

  • Client stubs, i.e., *C.h, *C.i, and *C.cpp. Pure client applications only need to #include and link with these files.
  • Server skeletons, i.e., *S.h, *S.i, and *S.cpp. Servers need to #include and link with these files.
  • Server skeleton templates, i.e., *S_T.h, S_T.i, and *S_T.cpp. Some C++ compilers do not like template and non-template code in the same files, so TAO's IDL compiler generates these files separately.

TAO's IDL compiler creates separate *.i and *S_T.* files to improve the performance of the generated code. For example, the *.i files enable you to compile with inlining enabled or not, which is useful for trading-off compile-time and run-time performance. Fortunately, you only need to #include the client stubs declared in the *C.h file and the skeletons in the *S.h file in your code.)

5.编译服务器端程序。开VC环境,建立一个Win32控制台工程,命名为Server,放在Server目录下(空工程)。在工程下新建一个C++ Sourse File,将服务器端代码写入(注意加入头文件#include"timeS.h"|#include"timeC.h")。将Server目录下的文件Server.cpp、times.cpp、timeC.cpp、timeS_T.cpp加入Sourse Files目录,将timeC.h、timeS.h、timeS_T.h、timeS_T.i加入Header Files目录。全部重建。得到Server.exe文件。

6.编译客户端程序。前面的步骤同服务器端。将Client.cpp、timeC.cpp加入Sourse Files目录,将timeC.h、timeS.h、timeC.i加入Header Files目录。全部重建。得到Client.exe文件。

7.运行程序。打开DOS环境,运行SERVER.exe ,它将输出一个引用给它的Time对象IOR。

Trouble:发现无法将IOR传递给客户机,改进服务器端程序

ofstream out("ior");

……

out << str <<endl;

out.close();

将得到的字符串放到一个“ior”的文件中,将它提出写入客户机端的程序中,得到格林威治时间。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值