Omnet++: class not found when called as a submodule of a compound module
<p>I am creating a simple omnet++ simulation. Part of that simulation uses a simple module called a <em>packet generator</em>. It will become part of a compound module inside a project called <em>complete</em>. However, when I try to use <em>packetGenerator</em> in a compound module, I get the following error message when trying to run a simulation:</p>

<blockquote>
  <p>Error in module (omnetpp::cModule) net.tx (id=2) during network setup: Class "packetGenerator" not found -- perhaps its code was not linked in, or the class wasn't registered with Register_Class(), or in the case of modules and channels, with Define_Module()/Define_Channel().</p>
</blockquote>

<p>Yes, I went into properties-->project references and referred to the <em>packetGenerator</em> project (as seen in the image). I have also called Define_Module(packetGenerator), as seen in <strong>packetGenerator.cc</strong></p>

<p>I have deduced that the problem occurs in the <em>submodules</em> section of the compound module, but I am not sure how to fix this. Any assistance is appreciated. If I omit the inclusion of the <em>packetGenerator</em> submodule in the <em>TransmitterNode</em> compound module, then the simulation will run fine (and do nothing, since there is no functionality yet).</p>

<p><strong>packetGenerator.cc</strong> (inside the project <em>packetGenerator</em>)</p>

<pre><code>#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include &lt;omnetpp.h&gt;
#include &lt;AppMessage_m.h&gt;
using namespace omnetpp;

//Simple module responsible for continuously generating AppMessage messages
class packetGenerator: public cSimpleModule {

  private:
    cMessage* event;
    int seqno;
    int senderId;

  public:
    packetGenerator();
    virtual ~packetGenerator();

  protected:

    virtual void initialize() override;

    virtual void handleMessage(cMessage *msg) override;

    virtual AppMessage* generateMessage();
};

Define_Module(packetGenerator);

packetGenerator::packetGenerator() {
    event = nullptr;
    seqno = 0;
}

packetGenerator::~packetGenerator() {
    cancelAndDelete(event);
}

void packetGenerator::initialize() {

    senderId = par("nodeIdentifier");
    event = new cMessage("event");
    scheduleAt(0.0, event);
}

void packetGenerator::handleMessage(cMessage* msg) {

    WATCH(seqno);

    //Go here when the new message is scheduled to be sent (after the delay)
    if (msg == event) {
        send(generateMessage(), "out");
        simtime_t delay = par("iatDistribution");
        scheduleAt(simTime() + delay, event);
    }

    //If we receive a message that isn't our timer-expiry message (e.g. from the MAC), go here
    else {
        AppMessage* appmsg = check_and_cast&lt;AppMessage*&gt;(msg);
        EV &lt;&lt; "Message received" &lt;&lt; endl;
        EV &lt;&lt; "Message kind: " &lt;&lt; msg-&gt;getKind() &lt;&lt; endl;
        delete appmsg;
    }

}

AppMessage* packetGenerator::generateMessage() {


    simtime_t timeStamp = simTime();
    int sequenceNumber = seqno;
    seqno++;
    int msgSize = par("messageSize");

    char messageName[30];
    sprintf(messageName, "Message from %d", senderId);

    AppMessage* msg = new AppMessage(messageName);
    msg-&gt;setTimeStamp(timeStamp);
    msg-&gt;setSenderId(senderId);
    msg-&gt;setSequenceNumber(sequenceNumber);
    msg-&gt;setMsgSize(msgSize);

    return msg;
}
</code></pre>

<p><strong>net.ned</strong> (inside the project <em>complete</em>)</p>

<pre><code>package complete;
import packetgenerator.packetGenerator;

module TransmitterNode
{
    parameters:
        int nodeIdentifier; //These need to be unique in the simulation
        double nodeXPosition;
        double nodeYPosition;
        @display("bgb=468,188;i=device/cellphone");
    gates:
    submodules:      
        packetGenerator: packetGenerator {
            @display("p=79,90;i=block/source");
        }
    connections:
}

network net
{
    submodules:
        tx: TransmitterNode;
    connections:
}
</code></pre>

<p><a href="https://i.stack.imgur.com/JYExd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JYExd.png" alt="properties"></a></p>