1
votes

During the build of my new OMNeT++ project I have encountered following error:

out/clang-debug//myUdp.o:(.rdata[_ZTI5myUdp]+0x10): undefined reference to 'typeinfo for inet::ApplicationBase'

I have already configured INET reference (Project "myUdp" -> Properties -> Project reference -> inet checkbox selected)

This is INET Makemake configuration: Target tab and Compile tab

This is Makemake configuration of my project (myUdp): Compile tab and Link tab

And the C++ code:

MyUdp.cc

#include <inet/applications/udpapp/UDPBasicApp.h>
class myUdp: public inet::UDPBasicApp {
};
Define_Module(myUdp);

MyUdp.ned

import inet.applications.udpapp.UDPBasicApp;
simple myUdp extends UDPBasicApp {
    @class(myUdp);
}

Can somebody help me to solve this error?

1

1 Answers

0
votes

That is probably because UDPBasicApp's methods are defined as virtual.

Compare the GCC infos on "vague linking" from http://gcc.gnu.org/onlinedocs/gcc/Vague-Linkage.html, for example this part:

type_info objects

C++ requires information about types to be written out in order to implement dynamic_cast, typeid and exception handling. For polymorphic classes (classes with virtual functions), the type_info object is written out along with the vtable so that dynamic_cast can determine the dynamic type of a class object at run time. For all other types, we write out the type_info object when it is used: when applying typeid to an expression, throwing an object, or referring to a type in a catch clause or exception specification.

You would need to provide either a definition for the virtual functions in the base class (UDPBasicApp) or declare them pure, because the compiler (GCC or Clang in your case) is trying to determine the right method for the translation unit (where the vtable and typeinfo objects are then created) and it cannot determine it correctly apparently.