I try to make my own traffic generator module inheriting INET EtherTrafGen in omnet++, only resulting in duplicate symbol error. I can't figure out the reason. Below are the compile error messages.
..
Creating executable: ../out/clang-release/src/hdc.exe
lld-link: error: duplicate symbol: inet::OperationalMixin<omnetpp::cSimpleModule>::isUp() const
>>> defined at ../out/clang-release/src/TrafGen.o
>>> defined at libINET.dll
lld-link: error: duplicate symbol: inet::OperationalMixin<omnetpp::cSimpleModule>::isDown() const
>>> defined at ../out/clang-release/src/TrafGen.o
>>> defined at libINET.dll
clang++: error: linker command failed with exit code 1 (use -v to see invocation
..
The corresponding header file, i.e. TrafGen.h is
#include "inet/applications/ethernet/EtherTrafGen.h"
namespace inet {
//class TrafGen : public cSimpleModule ----> In this case, no compile error
class TrafGen : public EtherTrafGen
{
protected:
virtual void initialize() override;
virtual void handleMessage(cMessage *msg) override;
};
}
and the corresponding TrafGen.cc file is
#include "TrafGen.h"
namespace inet {
Define_Module(TrafGen);
void TrafGen::initialize()
{
if (strcmp("hostA", getName()) == 0) {
cMessage *msg = new cMessage("hdcMsg");
send(msg, "out");
}
}
void TrafGen::handleMessage(cMessage *msg)
{
send(msg, "out"); // send out the message
}
}
TrafGen.ned is
import inet.applications.ethernet.EtherTrafGen;
simple TrafGen extends EtherTrafGen
{
parameters:
@class(inet::TrafGen);
}
By the way, when the TrafGen: public 'cSimpleModule' is used instead of 'EtherTrafGen' in the definition of TrafGen in the TrafGen.h, no compile error (duplicate symbol error) occurs.