linux下如何用ice?我明明在linux下编译了ice可是用ice出错

maguic 2009-02-18 10:11:47
In file included from ConfigBox.cpp:1:
ConfigBox.h:4:21: Ice/Ice.h: 没有那个文件或目录
In file included from ConfigBox.cpp:1:
ConfigBox.h:7: error: `IceUtil' has not been declared
ConfigBox.h:7: error: expected init-declarator before '<' token
ConfigBox.h:7: error: expected `,' or `;' before '<' token
ConfigBox.h:9: error: `IceUtil' has not been declared
ConfigBox.h:10: error: expected class-name before '{' token
ConfigBox.h:13: error: ISO C++ forbids declaration of `ConfigBoxPtr' with no type
ConfigBox.h:13: error: expected `;' before '&' token
ConfigBox.h:15: error: `Ice' has not been declared
ConfigBox.h:15: error: ISO C++ forbids declaration of `CommunicatorPtr' with no type
ConfigBox.h:15: error: expected `;' before "GetCommunicator"
ConfigBox.h:16: error: `Ice' has not been declared
ConfigBox.h:16: error: ISO C++ forbids declaration of `PropertiesPtr' with no type
ConfigBox.h:16: error: expected `;' before "GetProperties"
ConfigBox.h:17: error: using-declaration for non-member at class scope
ConfigBox.h:17: error: expected `;' before '&' token
ConfigBox.h:19: error: `Ice' has not been declared
ConfigBox.h:19: error: expected `,' or `...' before '&' token
ConfigBox.h:19: error: ISO C++ forbids declaration of `CommunicatorPtr' with no type
ConfigBox.h:20: error: `Ice' has not been declared
ConfigBox.h:20: error: expected `,' or `...' before '&' token
ConfigBox.h:20: error: ISO C++ forbids declaration of `PropertiesPtr' with no type
ConfigBox.h:21: error: expected unqualified-id before '&' token
ConfigBox.h:21: error: expected `,' or `...' before '&' token
ConfigBox.h:21: error: ISO C++ forbids declaration of `parameter' with no type
...全文
912 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
shenxiaoan123 2011-04-07
  • 打赏
  • 举报
回复
楼主问题解决了没有啊?我也遇到类似的问题,我在linux下用eclipse软件的插件g++来编译ice
, 我只是想试试,就用了一个客户端的例子,hello world,但是编译老是出错! 我的版本是3.3.1
帮帮忙啊
  • 打赏
  • 举报
回复
。。哎,看来是环境变量的问题。
yutaooo 2009-02-18
  • 打赏
  • 举报
回复

下面是个例子:



export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../Ice-3.0.1/lib



这是为了把 ICE 库目录追加加到原来的 LD_LIBRARY_PATH 后。用冒号分隔。
maguic 2009-02-18
  • 打赏
  • 举报
回复
LD_LIBRARY_PATH 怎么设置?我上网看看有没有相关的文章
yutaooo 2009-02-18
  • 打赏
  • 举报
回复

^_^
maguic 2009-02-18
  • 打赏
  • 举报
回复
实在太感谢你!我终于解决那个问题!准备给分
yutaooo 2009-02-18
  • 打赏
  • 举报
回复

哦。。。最好再把 LD_LIBRARY_PATH 这个环境变量设置好
yutaooo 2009-02-18
  • 打赏
  • 举报
回复

库的最好也加掉。



LDFLAGS += -L Ice-3.0.1/lib



我用的 ICE 版本跟你的不同。目录层次不一样。你要自己找找。
yutaooo 2009-02-18
  • 打赏
  • 举报
回复

c++ 是 g++ 的符号链接。

我第一个帖子误解了。你编译 ICE 库看来没有问题。问题出在你的默认头文件目录设置不正确。要把 Ice-3.0.1/include 加到目录里。

效果应该于下类似



g++ -IIce-3.0.1/include <其它参数...>
maguic 2009-02-18
  • 打赏
  • 举报
回复
只加Ice-3.0.1/include就可以了?
maguic 2009-02-18
  • 打赏
  • 举报
回复
我已经将
19、将config文件夹下的Make.rules.Linux,将c++改为g++
20、将config文件夹下的Make.rules里面的变量修改为第三方库的路径,找?号的是系统已经安装的,在linux下STL就是STLport不用另行安装。
yutaooo 2009-02-18
  • 打赏
  • 举报
回复

INCPATH 里加上 Ice-3.0.1/include
maguic 2009-02-18
  • 打赏
  • 举报
回复
3.0.1
yutaooo 2009-02-18
  • 打赏
  • 举报
回复

哪个版本的 ICE ?

我记得 ICE 编译的时候,要先到 config/Make.rules 里改一些配置的。
maguic 2009-02-18
  • 打赏
  • 举报
回复
以下是我makefile的内容
#############################################################################
# Makefile for building: monitor
# Generated by qmake (1.07a) (Qt 3.3.3) on: Wed Feb 18 09:39:34 2009
# Project: monitor.pro
# Template: app
# Command: $(QMAKE) -o Makefile monitor.pro
#############################################################################

####### Compiler, tools and options

CC = gcc
CXX = g++
LEX = flex
YACC = yacc
CFLAGS = -pipe -Wall -W -O2 -g -pipe -m32 -march=i386 -mtune=pentium4 -DEBUG -DQT_SHARED -DQT_THREAD_SUPPORT
CXXFLAGS = -pipe -Wall -W -O2 -g -pipe -m32 -march=i386 -mtune=pentium4 -DEBUG -DQT_SHARED -DQT_THREAD_SUPPORT
LEXFLAGS =
YACCFLAGS= -d
INCPATH = -I/usr/lib/qt-3.3/mkspecs/default -I. -I. -IIce-3.0.1/src/FreezeScript/dummyinclude -IIce-3.0.1/src/icecpp -IIce-3.0.1/src/IcePatch2 -IIce-3.0.1/src/slice2cpp -IIce-3.0.1/demo/book/evictor -IIce-3.0.1/demo/book/simple_filesystem -IIce-3.0.1/demo/Freeze/library -IIce-3.0.1/demo/Freeze/phonebook -IIce-3.0.1/demo/Glacier2/callback -IIce-3.0.1/demo/Glacier2/chat -IIce-3.0.1/demo/Ice/callback -IIce-3.0.1/demo/Ice/hello -IIce-3.0.1/demo/Ice/invoke -IIce-3.0.1/demo/Ice/nested -IIce-3.0.1/demo/Ice/session -IIce-3.0.1/demo/Ice/throughput -IIce-3.0.1/demo/Ice/value -IIce-3.0.1/demo/IceBox/hello -IIce-3.0.1/demo/IcePatch2/MFC -IIce-3.0.1/demo/Ice/MFC/client -IIce-3.0.1/demo/IceStorm/clock -IIce-3.0.1/test/Freeze/evictor -IIce-3.0.1/test/include -IIce-3.0.1/test/Ice/adapterDeactivation -IIce-3.0.1/test/Ice/exceptions -IIce-3.0.1/test/Ice/location -IIce-3.0.1/test/IceUtil/thread -IIce-3.0.1/demo/Ice/MFC/server -I$(QTDIR)/include
LINK = g++
LFLAGS =
LIBS = $(SUBLIBS) -L$(QTDIR)/lib -L/usr/X11R6/lib -lqt-mt -lXext -lX11 -lm
maguic 2009-02-18
  • 打赏
  • 举报
回复
以下是comfigbox.h的代码
#ifndef __ListenerC_Config_h__
#define __ListenerC_Config_h__

#include <Ice/Ice.h>

class ConfigBox;
typedef IceUtil::Handle<ConfigBox> ConfigBoxPtr;

class ConfigBox : public IceUtil::Shared
{
public:

static ConfigBoxPtr& instance();

Ice::CommunicatorPtr GetCommunicator();
Ice::PropertiesPtr GetProperties();
std::string& GetServerProxyID();

bool SetCommunicator(const Ice::CommunicatorPtr& ic);
bool SetProperties(const Ice::PropertiesPtr&);
bool SetServerProxyID(const std::string&);

private:
Ice::CommunicatorPtr _communicator;
Ice::PropertiesPtr _properties;
std::string _proxyId; //服务器代理连接串


static ConfigBoxPtr _instance;
static IceUtil::StaticMutex _instanceMutex;
};

#endif
yuzl32 2009-02-18
  • 打赏
  • 举报
回复
确认Ice/Ice.h的路径是否正确
yutaooo 2009-02-18
  • 打赏
  • 举报
回复

你找一下.



$(ICE_HOME)/lib/libIceUtil.so



看看是不是有这个文件。这个文件是你要链接的。改动你的 Makefile 使得最终能执行这样的命令行:



g++ -L../Ice-3.0.1/lib -lIceUtil <其它选项...>



另外,你问新问题,能不能发新帖啊! 我小赚点分拉。嘿嘿~~
maguic 2009-02-18
  • 打赏
  • 举报
回复
StatusThread.o(.text+0x51):../ice/Ice-3.0.1/include/IceUtil/Mutex.h:299: undefined reference to `IceUtil::Thread::~Thread()'

65,211

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧