ubuntu 14.04下是可以通过下面这条指令安装ice3.5的

sudo apt-get install libzeroc-ice35-dev

1. 从这里下载ice源文件

主要包括两部分:ice3.5.1.tar.gz和第三方依赖包ThirdParty-Sources-3.5.1.tar.gz

2. 安装第三方依赖

第三方依赖包中只含有berkely DB和mcpp两个依赖包,还缺少bzip、expat、openssl。

2.1) 安装berkely DB

$tar xvf ThirdParty-Sources-3.5..tar.gz
$cd ThirdParty-Sources-3.5.
$tar zxvf db-5.3..NC.tar.gz
$cd db-5.3..NC/
$patch -p0 < ../db/patch.db.5.3.
$cd build_unix/
$../dist/configure --prefix=/usr --enable-cxx
$make && make install

2.2) 安装mcpp

$tar xvf mcpp-2.7..tar.gz
$cd mcpp-2.7.
$patch -p0 < ../mcpp/patch.mcpp.2.7.
$./configure CFLAGS=-fPIC --prefix=/usr --enable-mcpplib --disable-shared
$make && make install

2.3) 安装bzip[下载]

$tar zxvf bzip2-1.0..tar.gz
$cd bzip2-1.0./
$make && make install

错误提示:/usr/bin/ld: /usr/local/lib/libbz2.a(bzlib.o): relocation R_ARM_THM_MOVW_ABS_NC against `BZ2_crc32Table’ can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libbz2.a: error adding symbols: Bad value
解决:bzip没有装好,一般是64 位 电脑才会出现。上面已经提示了recompile with
-fPIC。所以回到bzip目录,修改Makefile文件,CC = gcc —> CC = gcc -fPIC,再次make
&& make install

2.4) 安装expat[下载]

$tar jxvf expat-2.1..tar.bz2
$cd expat-2.1./
$./configure --prefix=/usr
$make && sudo make install

2.5) 安装openssl[下载]

$unzip OpenSSL_0_9_8-stable.zip
$cd openssl-OpenSSL_0_9_8-stable/
$./config --prefix=/usr --openssldir=/usr/openssl(openssldir默认为/usr/ssl/openssl,需要修改,否则默认安装路径会找不到。)
$make
$make test
$sudo make install

错误提示:/usr/bin/ld: /usr/lib/gcc/arm-linux-gnueabihf/4.9/../../../../lib/libssl.a(s23_meth.o): relocation R_ARM_THM_MOVW_ABS_NC against `a local symbol’ can not be used when making a shared object; recompile with -fPIC
解决:这个错误和问题2是一样的,因此修改Makefile文件,CC = gcc —> CC = gcc -fPIC,再次make && make install

3. 安装ice

$tar zxvf v3.5.1.tar.gz
$cd ice-3.5./cpp/ (这里只是安装了ice的c++模块)
$make && sudo make install

大概等了20多分钟报错,

make[]: Leaving directory `/root/ice_ws/ice_source/ice-3.5./cpp/demo/book/map_filesystem'
make[]: Leaving directory `/root/ice_ws/ice_source/ice-3.5./cpp/demo/book'
make[]: Leaving directory `/root/ice_ws/ice_source/ice-3.5./cpp/demo'
make[]: Leaving directory `/root/ice_ws/ice_source/ice-3.5./cpp'
making all in java
make[]: Entering directory `/root/ice_ws/ice_source/ice-3.5./java'
ant -emacs
make[]: ant: Command not found
make[]: *** [all] Error
make[]: Leaving directory `/root/ice_ws/ice_source/ice-3.5./java'
make: *** [all] Error

发现是java环境需要的ant,直接进入makefile进行修改,因为此处开发只需要用到c++,并且需要进行移植,所以将makefile修改成下面内容:

# **********************************************************************
#
# Copyright (c) - ZeroC, Inc. All rights reserved.
#
# This copy of Ice is licensed to you under the terms described in the
# ICE_LICENSE file included in this distribution.
#
# ********************************************************************** SUBDIRS = cpp
CLEAN_SUBDIRS = cpp
DEPEND_SUBDIRS = cpp
INSTALL_SUBDIRS = cpp all::
@for subdir in $(SUBDIRS); \
do \
echo "making all in $$subdir"; \
( cd $$subdir && $(MAKE) all ) || exit ; \
done clean::
@for subdir in $(CLEAN_SUBDIRS); \
do \
echo "making clean in $$subdir"; \
( cd $$subdir && $(MAKE) clean ) || exit ; \
done depend::
@for subdir in $(DEPEND_SUBDIRS); \
do \
echo "making depend in $$subdir"; \
( cd $$subdir && $(MAKE) depend ) || exit ; \
done install::
@for subdir in $(INSTALL_SUBDIRS); \
do \
echo "making install in $$subdir"; \
( cd $$subdir && $(MAKE) install ) || exit ; \
done test::
@for subdir in $(SUBDIRS); \
do \
echo "making test in $$subdir"; \
( cd $$subdir && $(MAKE) test ) || exit ; \
done cpp::
echo "making all in cpp";
( cd cpp && $(MAKE) all ) || exit ;

然后make && make  install,通过。

5. 测试用例

建立一个print目录,在该目录下:

建立ice文件demo.ice

module demo
{
interface printer
{
void printerstr(string msg);
}; };

运行下面的命令,会在print目录下生成demo.h和demo.cpp。

$slice2cpp demo.ice

发现没有slice2cpp这条指令,添加系统环境gedit /etc/environment

将生成的bin目录导入,或者在~/.bashrc里添加PATH

:/opt/Ice-3.5./bin

运行上面命令,报错如下:

slice2cpp: error while loading shared libraries: libSlice.so.: cannot open shared object file: No such file or directory

编译生成的环境加入到系统环境中gedit  ~/.bashrc

#在PATH中找到可执行文件程序的路径。
export PATH =$PATH:/opt/Ice-3.5./bin #g++找到头文件的路径
CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/opt/Ice-3.5./include
export CPLUS_INCLUDE_PATH #找到动态链接库的路径
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/Ice-3.5./lib
export LD_LIBRARY_PATH

保存,source ~/.bashrc,重新执行上述命令,OK,在print目录下生成demo.h和demo.cpp。

编写ice服务端server.cpp

#include <Ice/Ice.h>
#include <demo.h>
using namespace demo;
using namespace std;
class PrinterI : public printer {
public:
virtual void printerstr(const string & s,
const Ice::Current &);
};
void
PrinterI::
printerstr(const string & s, const Ice::Current &)
{
cout << s << endl;
}
int
main(int argc, char* argv[])
{
int status = ;
Ice::CommunicatorPtr ic;
try {
ic = Ice::initialize(argc, argv);
Ice::ObjectAdapterPtr adapter
= ic->createObjectAdapterWithEndpoints(
"SimplePrinterAdapter", "default -p 10000");
Ice::ObjectPtr object = new PrinterI;
adapter->add(object,
ic->stringToIdentity("SimplePrinter"));
adapter->activate();
ic->waitForShutdown();
} catch (const Ice::Exception & e) {
cerr << e << endl;
status = ;
} catch (const char * msg) {
cerr << msg << endl;
status = ;
}
if (ic)
ic->destroy();
return status;
}

编写ice客户端client.cpp

#include <Ice/Ice.h>
#include <demo.h>
using namespace demo;
using namespace std; int
main(int argc, char * argv[])
{
int status = ;
Ice::CommunicatorPtr ic;
try {
ic = Ice::initialize(argc, argv);
Ice::ObjectPrx base = ic->stringToProxy(
"SimplePrinter:default -p 10000");
printerPrx printer = printerPrx::checkedCast(base);
if (!printer)
throw "Invalid proxy";
printer->printerstr("Hello World!");
} catch (const Ice::Exception & ex) {
cerr << ex << endl;
status = ;
} catch (const char * msg) {
cerr << msg << endl;
status = ;
}
if (ic)
ic->destroy();
return status;
}

编译并运行客户端和服务端,如果hello world打印出来,那么就是安装成功了。

$ g++ demo.cpp server.cpp -lIce -L/opt/Ice-3.5./lib -lIceUtil -lpthread -o server
$ g++ demo.cpp client.cpp -lIce -L/opt/Ice-3.5./lib -lIceUtil -lpthread -o client
$ ./server $./client
Hello World!

至此,安装成功!!!

原文参考http://blog.csdn.net/w1282109144/article/details/51426361

ubuntu14.04下安装ice3.5.1的更多相关文章

  1. Ubuntu14.04下安装Hadoop2.5.1 (单机模式)

    本文地址:http://www.cnblogs.com/archimedes/p/hadoop-standalone-mode.html,转载请注明源地址. 欢迎关注我的个人博客:www.wuyudo ...

  2. 二、Ubuntu14.04下安装Hadoop2.4.0 (伪分布模式)

    在Ubuntu14.04下安装Hadoop2.4.0 (单机模式)基础上配置 一.配置core-site.xml /usr/local/hadoop/etc/hadoop/core-site.xml ...

  3. Ubuntu14.04下安装Flash Player

    Ubuntu14.04下安装Flash Player youhaidong@youhaidong:~$ sudo apt-get install flashplugin-nonfree [sudo] ...

  4. Ubuntu14.04下 安装p4c

    参考: Github p4c README Ubuntu14.04下 安装p4c 这里提供一个直接安装p4c的脚本:install_p4c.sh. 1.git clone下来p4c: $ git cl ...

  5. Ubuntu14.04下安装Libsvm,并使用Libsvm

    (1)Ubuntu14.04下安装Libsvm 转载:https://blog.csdn.net/katrinawj/article/details/78915874 一.下载: 网址:http:// ...

  6. ubuntu14.04下安装ffmpeg

    ubuntu14.04下安装ffmpeg 一.安装各种依赖包 1.yasm(libx264需要依赖yasm) sudo apt-get install yasm 2.libx264 sudo apt- ...

  7. ubuntu14.04下安装cudnn5.1.3,opencv3.0,编译caffe及配置matlab和python接口过程记录

    已有条件: ubuntu14.04+cuda7.5+anaconda2(即python2.7)+matlabR2014a 上述已经装好了,开始搭建caffe环境. 1. 装cudnn5.1.3,参照: ...

  8. 在Ubuntu14.04下安装Docker CE(1) - repository篇

    从2017年3月开始,Docker开始分为社区版本和企业版,也就是Docker CE和Docker EE, 原来Ubuntu14.04下,通过sudo apt-get install docker.i ...

  9. ubuntu14.04下安装爬虫工具scrapy

    scrapy是目前准备要学习的爬虫框架,其在ubuntu14.04下的安装过程如下: ubuntu14.04下默认安装了2.7的python以及setuptools,若未安装,可通过下面指令安装: s ...

随机推荐

  1. web前端安全---读书笔记

    web前端安全---读书笔记 粗略的看完了Web前端黑客技术揭秘前两章了,由于自身的前端功力不深,当然也是初涉前端的安全问题,所以实话还是有些问题看不太明白的.在豆瓣看到的这本书,名字真心有点很肥主流 ...

  2. 抛掉kendoUI的MultiSelect,自己实现 DropDownList MultiSelect

    我们首先来看下kendoUI官方的下拉框多选: 再来看看telerik RadControls的下拉框多选: 很明显从展现形式上来看,第二种是优于第一种的,至少我是这么认为的 :-) 那我们就对Dro ...

  3. c# 关于10进制和16进制转换以及显示

    直接举例说明: int i = 15;//一个10进制数 string txt = Convert.ToString(i,16);//将上面10进制以16进制形式显示为f string s = &qu ...

  4. Centos 上使用mmsh协议听猫扑网络电台 VLC播放器

    Centos 上使用mmsh协议听猫扑网络电台 VLC播放器 安装CentOS已经有一段时间了,但是由于在Linux下除了学习,其他是事情都干不了.今天想闲来无事开了CentOS就想听一下歌,突然想起 ...

  5. Arduino 不同Arduino衍生板子的问题

    arduino IDE装上的时候,要记得在windows平台安装驱动. 如果不安装驱动的话,烧写程序的时候也许会遇到下面的现象. 原因有如下几种: 1,arduino控制板或者COM口没有选对,这种问 ...

  6. C++ 容器的综合应用的一个简单实例——文本查询程序

    C++ 容器的综合应用的一个简单实例——文本查询程序 [0. 需求] 最近在粗略学习<C++ Primer 4th>的容器内容,关联容器的章节末尾有个很不错的实例.通过实现一个简单的文本查 ...

  7. ASP.NET控件Repeter的使用

    使用repeter控件,绑定数据源,能够省去在前台页面中拼接繁杂的for.foreach的时间,整个页面看起来也更加直观.常配合<select>标签.<table>标签使用. ...

  8. angularJs中自定义directive的数据交互

    首先放官方文档地址:https://docs.angularjs.org/guide/directive 就我对directive的粗浅理解,它一般用于独立Dom元素的封装,应用场合为控件重用和逻辑模 ...

  9. 用Vue中遇到的问题和处理方法(一)

    用Vue开发项目有一段时间,在实际项目中遇到一些问题,在里把问题记录下来,并附上解决方案,给遇到同样的问题的码友提供一个解决思路吧: 测试部抛出问题一:在Vue1.0路由vue-router中,当点击 ...

  10. 浅谈敏捷组织中PMO的角色

    所谓的"敏捷组织"其实并没有标准的模式,而且PMO(项目管理办公室)并没有一个标准的角色定义.有一个非常普遍的误解,公司在选择"敏捷"或者"瀑布&qu ...