Reputation: 88
I'm beginner in OMNeT++ and I wrote a simple project and run it with OMNeT++. I got the following error:
Class "my_node" 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() -- in module (omnetpp::cModule) CDN (id=1), during network setup
I created an other project and wrote this again and also get that error. My c++ code is the following:
#include <string.h>
#include <omnetpp.h>
using namespace omnetpp;
class CDNClass : public cSimpleModule
{
protected:
virtual void initialize() override;
virtual void handleMessage(cMessage *msg) override;
};
Define_Module(CDNClass);
void CDNClass::initialize(){
if (strcmp("note1",getName())==0) {
cMessage *msg = new cMessage("data");
send(msg, "out");
}
}
void CDNClass::handleMessage(cMessage *msg){
send(msg,"out");
}
And my ned file is:
package proje_shabake;
//
// TODO auto-generated type
//
simple my_node
{
gates:
input in;
output out;
}
network CDN
{
submodules:
node1: my_node {
@display("p=40,54");
}
node2: my_node {
@display("p=158,62");
}
connections:
node1.out --> node2.in;
node2.out --> node1.in;
}
Also my ini file is:
[General]
network = CDN
Please help me to fix this problem.
Upvotes: 0
Views: 429
Reputation: 7002
By default OMNeT++ expects that C++ class of a simple module has the same name as the name of the simple module in NED.
The name of your simple module is my_node
, so the C++ class my_node
is expected. However, in your code there is no that class.
I suggest changing in your C++ code all instance of CDNClass
with my_node
.
By the way: in OMNeT++ there is an option to generate all files required by a simple module in a few steps. Choose File
| New
| Simple Module
.
Upvotes: 0