'C++/ Omnet++ Server.h:26: undefined reference to `omnetpp::cSimpleModule::~cSimpleModule()'

I have a Computer.cc/Computer.h script and a Server.cc/Server.h script within Omnet++ (see below): However, when I compile the project either Computer.cc/Computer.h OR Server.cc/Server.h "script duo" does not recognize omnetpp:cSimpleModule (and all the functions related to it) and other libraries (e.g. omnetpp.h). Here is what I mean: (1) Computer.h Module not found Error (2) Server.h Module not found error

The code is not changed in both images linked above!

What I have to do to "move" the error message to the other ".cpp/.h" script combination. Example:

If I have Computer.cc/.h "module not found error" I only have to delete their code and insert the same code again in both scripts (.cpp/.h) . Then compile again and the "module not found error" switches to the Server.cc/.h scripts. I have absolutely no idea why always only one combination of scripts can handle the libraries? Might this be a wrong compiler setting? Does anyone have an idea?

// Computer.h
#ifndef __TCP_COMPUTER_H_
#define __TCP_COMPUTER_H_

#include <omnetpp.h>

using namespace omnetpp;

/**
* TODO - Generated class
*/
class Computer : public cSimpleModule
{
 protected:
 virtual void initialize();
 virtual void handleMessage(cMessage *msg);
};

#endif


//Computer.cc
#include <iostream>
#include <string.h>
#include <winsock2.h>
#include <ws2tcpip.h>

#define NS_INADDRSZ  4
#define NS_IN6ADDRSZ 16
#define NS_INT16SZ   2

#include "Computer.h"
Define_Module(Computer);

using namespace std;

void Computer::initialize()
{
 ....
}
void Computer::handleMessage(cMessage *msg)
{
// ...

}



// Server.h
#ifndef __TCP_SERVER_H_
#define __TCP_SERVER_H_

#include <omnetpp.h>

using namespace omnetpp;

/**
* TODO - Generated class
*/
class Server : public cSimpleModule
{
protected:
virtual void initialize();
virtual void handleMessage(cMessage *msg);
};

#endif


// Server.cc
#include "Server.h"
Define_Module(Server);

void Server::initialize()
{
// TODO - Generated method body
}

void Server::handleMessage(cMessage *msg)
{
    // TODO - Generated method body
    cGate *arrivalGate = msg->getArrivalGate();

    if(arrivalGate == gate("in1")){

    std::string mes = msg->getFullName();

    char revString[mes.size()];
    // reverse
    int max = mes.size()-1;

    for(int i=0;i< mes.size();i++){
        revString[max--] = mes.at(i);
    }
    cMessage *Rmsg = new cMessage(revString);

    send(Rmsg,"out2");
}
}

Best regards, Lukas



Solution 1:[1]

Probably you have created a standard C++ project instead of OMNeT++ project. The simplest way to recognize the type of project is looking into Properties of your project. OMNeT++ project contains OMNeT++ branch, see picture below:

enter image description here

In order to create the OMNeT++ project use: File | New | OMNeT++ Project....

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1