Ubuntu installation Ice Record

Source: Internet
Author: User

Background
This document describes how to install ice in a unbuntu environment and write an ice application in C + +

About Ice
Ice is the Zeroc Open Source Communication protocol product, its full name is: The Internet Communications engine, translated into Chinese is the Internet communications engines, is a popular object-oriented toolkit, so that we can build distributed applications at the lowest cost. Ice allows us to focus on the development of application logic, which handles all the underlying programming of the network interface, so we don't have to consider the details of opening the network connection, serialization and deserialization of the network data transfer, attempts to fail the connection, and so on.

The first part
Download
SOURCE Download Link: poke here

Compiling the installation
Tar zxvf ice-3.6.0.tar.gz
CD Ice-3.6.0/cpp
Make
Make install

Problems & Workarounds encountered
1) Connectioni.cpp:28:19:error:bzlib.h: no file or directory
sudo apt-get install Libmcpp-dev

2).. /freeze/transactioni.h:15:20:error:db_cxx.h: No file or directory
To install Berkeley DB, refer to: poke here
BDB Environment Configuration:
Export db_home=/usr/local/berkeleydb.4.6
Path= $PATH: $DB _home/bin
. . BASHRC

Part II
1. Create an ice file Printer.ice

module Demo {    interface  Printer {        void printstring (string  s );    };};

2.Compiling a Slice Definition for C + +
$ slice2cpp Printer.ice

3. Create Server.cpp

#include <Ice/Ice.h>#include<Printer.h>using namespacestd;using namespaceDemo;classPrinteri: PublicPrinter { Public:Virtual voidPrintstring (Const string& S,Constice::current&);};voidprinteri::p rintstring (Const string& S,Constice::current&) {cout<< s <<Endl;}intMain (intargcChar*argv[]) {intStatus =0; ice::communicatorptr ic;Try{IC=ice::initialize (argc, argv); Ice::objectadapterptr Adapter=IC->createobjectadapterwithendpoints ("Simpleprinteradapter","default-p 10000"); Ice::objectptrObject=NewPrinteri;adapter->add (Object, Ic->stringtoidentity ("Simpleprinter")); adapter-activate (); IC-Waitforshutdown ();} Catch(Constice::exception&e) {Cerr<< e <<Endl;status=1;} Catch(Const Char*msg) {Cerr<< msg <<Endl;status=1;}if(IC) {Try{IC-destroy ();} Catch(Constice::exception&e) {Cerr<< e <<Endl;status=1;}}returnstatus;}

4. Create Client.cpp

#include <Ice/Ice.h>#include<Printer.h>using namespacestd;using namespaceDemo;intMain (intargcChar*argv[]) {intStatus =0; ice::communicatorptr ic;Try{IC=ice::initialize (argc, argv); Ice::objectprxBase= Ic->stringtoproxy ("simpleprinter:default-p 10000"); Printerprx Printer= Printerprx::checkedcast (Base);if(!printer)Throw "Invalid Proxy";p Rinter->printstring ("Hello world!");} Catch(Constice::exception&ex) {Cerr<< ex <<Endl;status=1;} Catch(Const Char*msg) {Cerr<< msg <<Endl;status=1;}if(IC) ICS-destroy ();returnstatus;}

5. Testing

1. Environment configuration
Export ice_home=/opt/ice-3.6.0
Export ld_library_path= $LD _library_path: $DB _home/lib64:/home/bran/ice-3.6.0/cpp

$ c +-I.-i$ice_home/include-c Printer.cpp Server.cpp
$ c + +-o server printer.o server.o-l$ice_home/lib-lice-liceutil

$ c +-I.-i$ice_home/include-c Printer.cpp Client.cpp
$ c + O client printer.o client.o-l$ice_home/lib-lice-liceutil

Ubuntu installation Ice Record

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.