Archived

This forum has been archived. Please start a new discussion on GitHub.

link error when the class is inherited from ICE::Object

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++:confused:

will you tell me why and how to slove it ?:confused:

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;
}
//

Comments

  • matthew
    matthew NL, Canada
    You need to give much more information if you want help. What libraries are you linking with? Did you look at how the demos are linked? If so, then that should give you a good idea about how to link your application.
  • 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 lot
  • the attachment is here
  • marc
    marc Florida
    This should be:
    -L$ICE_HOME/LIB -lIce -lIceUtil
    

    What link errors do you get? Please cut&paste the errors here.
  • i pasted the link errors in the attachment file named linkerrors.txt.
    please help me.:mad:
  • marc
    marc Florida
    As I wrote in my last post, your link line is wrong. Change:
    iceTest: TestMain.cpp
    	g++ -o iceTest TestMain.cpp $(objects)  -L$ICE_HOME/LIB -LIce -lIceUtil
    

    To:
    iceTest: TestMain.cpp
    	g++ -o iceTest TestMain.cpp $(objects)  -L$ICE_HOME/LIB -lIce -lIceUtil
    
  • :( i am sorry to make such a silly mistake.

    In my previous ice program , i use "-L$ICE_HOME/LIB -LIce -lIceUtil" and it works.

    thank you very very very much.:D