Search code examples
eclipse-cdtomnet++

OMNeT++: Error in module during network setup: Class not found


I created my first OMNeT++/veins project, but can’t start the simulation. Can you help me?

I would like to change my question - is there a simple way to create a project, similar to RSUExampleScenario of veins, not under veins/examples/myfolder, but in a separate project and workspace? And what steps must I do for it?

I wanted to create a project similar to RSUExampleScenario from veins, but with other scenario and using other OMNeT++ modules. As I created my project under veins/examples/myfolder, and put my new .ned files under veins structure, it worked fine.

Now I created new project, including folders with .ned and c++/h files, like folder connection (Connection.ned, Connection.cc, Connection.h, package.ned) and folder node (CloudVehicleScenarioMessage.ned, Cloud.ned) and simulation folder cloudvehiclehi (omnetpp.ini).

When I start a simulation I receive the error:

Error in module (cCompoundModule) CloudVehicleScenarioMessage (id=1) during network setup: Class "Connection" 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().

I guess the NED files are loaded, but the classes in c++ files cannot be found, though I used Define_Module. Cloud is just a compound module, without any own c++ implementations, it creates no problems. Connection is a simple module, referring to class Connection.cc, where Define_Module() is called and causes the error while loading. All my folders, like node or connection are included, as I can see under Project->Properties->Paths and Symbols->Includes.

I already tried to rebuild OMNeT++ (as told here https://www.linkedin.com/grp/post/3801609-234767834) and to define namespaces for my classes (as told here Problem in defining a module in omnetpp), but it didn’t help.

I proved my makefile and the folders were linked in (as told here https://groups.google.com/forum/#!topic/omnetpp/Cl48hVgkbQ0).

CloudVehicleScenarioMessage.ned is my network in omnetpp.ini.

nodes/CloudVehicleScenarioMessage.ned:

package cloudbasedcsw.nodes;

import cloudbasedcsw.nodes.ScenarioMobility;
import cloudbasedcsw.nodes.Cloud;
import cloudbasedcsw.connection.Connection;

network CloudVehicleScenarioMessage extends ScenarioMobility
{
@display("bgb=540,555");
submodules:
    cloud[1]: Cloud {
        @display("p=150,140;b=10,10,oval");
    }
    con: Connection {
        @display("p=200,40;b=10,10,oval");
    }
}

ned file of module Connection:

connection/Connection.ned

package cloudbasedcsw.connection;

simple Connection{
    @class(CloudBasedCSW::Connection);
}

Class Connection, which can not be found:

connection/Connection.cc

#include <Connection.h>
#include <VehicleListener.h>
#include <iostream>
using CloudBasedCSW::Connection;

Define_Module(CloudBasedCSW::Connection);

void Connection::initialize(int stage){

}

void Connection::connectToCloud(cModule* node){
}

void Connection::disconnectFromCloud(cModule* node){
}

Connection.h

#ifndef CONNECTION_H_
#define CONNECTION_H_
#include <omnetpp.h>

namespace CloudBasedCSW{

class Connection: public cSimpleModule{
public:
    cModule* scenario;
    void connectToCloud(cModule* node);
    void disconnectFromCloud(cModule* node);
protected:
    virtual void initialize(int stage);
private:
    cModule* cloud;
    int currentId;
    int gateCloudInId;
    int gateCloudOutId;
};

}
#endif /* CONNECTION_H_ */

Solution

  • I guess that your class Connection is in CloudBasedCSW C++ namespace. Therefore in Connection.ned you should change @class(Connection); to @class(CloudBasedCSW::Connection);.