samedi 27 février 2021

undefined reference to in c++ / omnet++

I am using omnet++ that follows c++, I want to make one simple controller. I want to change the value of static members of the controller from another file. But when I compile the code it generates undefined references.

My code is written following, Kindly suggest to me what should I do, Thanks in advance.

//controlTest.h
namespace OPTxGsPON {
class controlTest:public cSimpleModule, public cListener 
{
public:
    static controlTest* bb;
    static int bbb;
};
}; //namespace
//User.h
namespace OPTxGsPON {
class User :public cSimpleModule
{
protected:
    virtual void initialize();
};
}; //namespace
//User.cc
namespace OPTxGsPON {
void User::initialize()
{
     controlTest::bb=new controlTest();
     controlTest::bbb=12;
}
}; //namespace

Error: ../out/gcc-release/src/User/User.o:User.cc:(.rdata$.refptr._ZN9OPTxGsPON11controlTest2bbE[.refptr._ZN9OPTxGsPON11controlTest2bbE]+0x0): undefined reference to `OPTxGsPON::controlTest::bb'

Please guide me How will I fix it...

Aucun commentaire:

Enregistrer un commentaire