Archived
This forum has been archived. Please start a new discussion on GitHub.
link error when the class is inherited from ICE::Object
nyingchi
in Help Center
The code works well under WINDOWS, the IDE is VS.NET 2003.:D
But, there are a lot of link errors under LINUX, the complier is g++
will you tell me why and how to slove it ?
i appreciate your help.;)
The code:
//
// MyObject.h
#ifndef MYOBJECT_H
#define MYOBJECT_H
#include <Ice/Ice.h>
#include <IceUtil/Handle.h>
class MyObject :public Ice::Object
{
public:
MyObject(void);
virtual ~MyObject(void) = 0 ;
virtual int get() const
{
return 0;
};
};
class TestObject : public MyObject
{
public:
TestObject(int val):MyObject(),_value(val)
{
};
~TestObject(){};
int get() const
{
return this->_value;
};
void set(int val)
{
this->_value = val;
}
private:
int _value;
};
typedef IceUtil::Handle<MyObject> MyObjectPtr;
#endif //MYOBJECT_H
//
// MyObject.cpp
#include "MyObject.h"
MyObject::MyObject(void)
{
}
MyObject::~MyObject(void)
{
}
//
// TestMain.cpp
#include "MyObject.h"
int main(int argc, char * argv[])
{
MyObjectPtr p = new TestObject(atoi(argv[1]));
std::cout << p->get();
// return 0;
}
//
But, there are a lot of link errors under LINUX, the complier is g++
will you tell me why and how to slove it ?
i appreciate your help.;)
The code:
//
// MyObject.h
#ifndef MYOBJECT_H
#define MYOBJECT_H
#include <Ice/Ice.h>
#include <IceUtil/Handle.h>
class MyObject :public Ice::Object
{
public:
MyObject(void);
virtual ~MyObject(void) = 0 ;
virtual int get() const
{
return 0;
};
};
class TestObject : public MyObject
{
public:
TestObject(int val):MyObject(),_value(val)
{
};
~TestObject(){};
int get() const
{
return this->_value;
};
void set(int val)
{
this->_value = val;
}
private:
int _value;
};
typedef IceUtil::Handle<MyObject> MyObjectPtr;
#endif //MYOBJECT_H
//
// MyObject.cpp
#include "MyObject.h"
MyObject::MyObject(void)
{
}
MyObject::~MyObject(void)
{
}
//
// TestMain.cpp
#include "MyObject.h"
int main(int argc, char * argv[])
{
MyObjectPtr p = new TestObject(atoi(argv[1]));
std::cout << p->get();
// return 0;
}
//
0
Comments
-
i omitted the makefile , sorry.
when i debuged under windows xp with VS.NET 2003, the ice lib i use are : iced.lib and iceuitld.lib.
and this code works normally.
Under linux , i use ".... -L$ICE_HOME/LIB -LIce -lIceUtil"
the attachment is my code source and makefile.
same link errors is recorded in linkerrors.txt.
please give me same advice and thank you a lot0 -
-
i pasted the link errors in the attachment file named linkerrors.txt.
please help me.:mad:0
