can't allocate an object of abstract type [INET error]

392 views
Skip to first unread message

Hanuma Chitti

unread,
Jul 9, 2013, 4:19:33 PM7/9/13
to omn...@googlegroups.com
Hello all,

I am trying to implement a queuing algorithm using INET framework in Omnet++ 4.2

I have implemented an algo [MyAlgo which is derived from PassiveQueueBase] and implemented all virtual functions those are present in PassiveQueueBase class.
-------------------------------
Define_Module(MyAlgo);
void MyAlgo::initialize()
{
PassiveQueueBase::initialize();
.....
}
bool MyAlgo::enqueue(cMessage *msg)
{.....
}
cMessage *MyAlgo::dequeue()
{.....
}
bool MyAlgo::isEmpty()
{....
}
void MyAlgo::sendOut(cMessage *msg)
{
    send(msg, outGate);
}
-----------------------------
While I do build, I keep getting an error "can't allocate object of abstract data type" pointing to "Define_Module(MyAlgo);"

Could you please let me know the problem if you have any idea about this.

Thanks in advance.
Regards
Sri

Rudolf Hornig

unread,
Jul 10, 2013, 4:52:39 AM7/10/13
to omn...@googlegroups.com
In my codebase PassiveQueueBase contains:

virtual cMessage *enqueue(cMessage *msg) = 0;

i.e. the return value is not bool as in your code.
Rudolf

Hanuma Chitti

unread,
Jul 10, 2013, 10:52:18 AM7/10/13
to omn...@googlegroups.com
Thanks a lot Rudolf.

It helped. But I had another problem with INET_API. I have seen your reply in another post in this forum to add a header "INETDefs.h" and "make makefiles". But still having an error.
MyAlgo.h
-------------
#ifndef __INET_MYALGO_H_
#define __INET_MYALGO_H_

#include <omnetpp.h>
#include "INETDefs.h"
#include "PassiveQueueBase.h"
#include <IPassiveQueue.h>

class INET_API MyAlgo : public PassiveQueueBase
{
Protected:
virtual void initialize();
..
..
virtual void finish();
};
#endif
--------------
I am getting the error like:
out/gcc-debug//MyAlgo.o: In function `MyAlgo':
H:\Simulator\omnetpp-4.2.2\samples\coalg/MyAlgo.h:18: undefined reference to `_imp___ZTV6MyAlgo'
H:\Simulator\omnetpp-4.2.2\samples\coalg/MyAlgo.h:18: undefined reference to `_imp___ZTV6MyAlgo'
out/gcc-debug//MyAlgo.o: In function `~MyAlgo':
H:\Simulator\omnetpp-4.2.2\samples\coalg/MyAlgo.h:18: undefined reference to `_imp___ZTV6MyAlgo'
H:\Simulator\omnetpp-4.2.2\samples\coalg/MyAlgo.h:18: undefined reference to `_imp___ZTV6MyAlgo'
collect2: ld returned 1 exit status
make: *** [out/gcc-debug//coalg.exe] Error 1
--------------

Please provide some hints if you see that I am missing some logic.

Alfonso Ariza Quintana

unread,
Jul 10, 2013, 1:06:38 PM7/10/13
to omn...@googlegroups.com

The undefined references are the constructor and destructor of the class, you should check both methods

--
--
Sent from the OMNeT++ mailing list. To configure your membership,
visit http://groups.google.com/group/omnetpp
 
---
You received this message because you are subscribed to the Google Groups "omnetpp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omnetpp+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages