ice开发环境搭建

ice开发环境搭建

ID:32366421

大小:244.51 KB

页数:5页

时间:2019-02-03

ice开发环境搭建_第1页
ice开发环境搭建_第2页
ice开发环境搭建_第3页
ice开发环境搭建_第4页
ice开发环境搭建_第5页
资源描述:

《ice开发环境搭建》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库

1、ICE开发环境搭建1.本文的开发环境为vc10.02.在官网上下载最新版本的ice开发包http://www.zeroc.com/download.html,最新为Ice-3.4.2.msi和Ice-3.4.2-ThirdParty.msi。3.安装完成后,设置环境变量,我的安装路径为C:ProgramFilesZeroCIce-3.4.2,C:ProgramFilesZeroCIce-3.4.2-ThirdParty,添加环境变量IceHome=C:ProgramFilesZeroCI

2、ce-3.4.2,IcePartyHome=C:ProgramFilesZeroCIce-3.4.2-ThirdParty,在Path环境变量中添加%IceHome%binvc100;%IceParthHome%binvc100,打开一个cmd窗口,输入slice2cpp–v,如果有版本信息输出,则设置成功。4.HelloWorld演示程序n使用notepad输入如下代码:modulePrinterICE{interfacePrinter{voidprintString(strings);}

3、;};保存为Printer.ice,打开一个控制台窗口,切换到Printer.ice目录下,运行slice2cppPrinter.ice,则可以看到生成了Printer.cpp和Printer.h文件。n使用vs2010新建一个solution,命名为hello_world,在该solution中分别添加client和server工程,在client和server工程中添加Printer.cpp和Printer.h的引用;client.cpp中输入如下代码#include#inclu

4、de"../ice_files/Printer.h"usingnamespacestd;usingnamespacePrinterICE;intmain(intargc,char*argv[]){intstatus=0;Ice::CommunicatorPtric;try{ic=Ice::initialize(argc,argv);Ice::ObjectPrxbase=ic->stringToProxy("SimplePrinter:default-p12000");PrinterPrxprinter=P

5、rinterPrx::checkedCast(base);if(!printer)throw"Invalidproxy";printer->printString("HelloWorld!");}catch(constIce::Exception&ex){cerr<destroy();returnstatus;}Server.cpp中添加如下代码:#in

6、clude#include"../ice_files/Printer.h"usingnamespacestd;usingnamespacePrinterICE;classPrinterI:publicPrinter{public:virtualvoidprintString(conststring&s,constIce::Current&);};voidPrinterI::printString(conststring&s,constIce::Current&){cout<

7、ndl;}intmain(intargc,char*argv[]){intstatus=0;Ice::CommunicatorPtric;try{ic=Ice::initialize(argc,argv);Ice::ObjectAdapterPtradapter=ic->createObjectAdapterWithEndpoints("SimplePrinterAdapter","default-p12000");Ice::ObjectPtrobject=newPrinterI;Ice::Identit

8、yit=ic->stringToIdentity("SimplePrinter");adapter->add(object,it);adapter->activate();ic->waitForShutdown();}catch(constIce::Exception&e){cerr<

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。