The problem I have is very similar to the one discussed here: g++ undefined reference to typeinfo
Even so, I believe I so not have the same issue, and the answers to that topi do not really help me. What i have is :
class Base
{
virtual ~Base() {}
virtual void foo() = 0;
// some other pure virtual behaviors
};
class Derived : public Base
{
void foo() {/* do stuff */}
// override for all other virtual behaviors
};
then in different functions I have :
void bar( Base * base )
{
Derived * derived = dynamic_cast<Derived *>(base);
}
void foobar( const Base & base1, const Base & base2 )
{
if ( typeid(base1) == typeid(base2) )
/* do something */;
}
So I'm sure the function is either pure virtual or defined (even though the object can never be Base). This should not give any problems, and it is different from the quoted discussion because i'm sure i override the virtual function. Even so, when compiling with clang++, it issues an unresolved external for both typeid and dynamic_cast when used on Derived, while it doesn't do so for other classes that inherit from Base, and override the same foo behaviors. Why does it do so?
here the errors:
error LNK2019: unresolved external symbol __imp___RTDynamicCast
error LNK2019: unresolved external symbol __imp___RTtypeid
Am i just missing something silly, or misinterpreting these errors?
Edit
I realized the code examples I first gave were not descriptive enough :
class Base
{
public:
virtual ~Base() {}
};
class Interface : public Base
{
public:
virtual void foo() = 0;
// some other pure virtual behaviors
};
class Derived : public Interface
{
public:
void foo() {/* do stuff */}
// override for all other virtual behaviors
};
and
void bar()
{
Base * base = new Derived;
Interface * interface = dynamic_cast<Interface *>(base);
interface->foo()
}
fit better to what i'm trying to do.