I'm working on a sample project with two modules: A and B(which links to A), using Xcode 4.4.
In module A, the symbols are hidden by the compiler flag -fvisibility=hidden. I have a class whose destructor is virtual and exported:
class utx
{
int mm;
public:
__attribute__ ((visibility("default"))) utx(int m);
__attribute__ ((visibility("default"))) virtual ~utx();
};
And it's implemented as:
utx::utx(int m) : mm(m) { }
utx::~utx() { }
In module B, MyUtx derives from utx as below:
class MyUtx : public utx
{
public:
MyUtx() : utx(5) { }
virtual ~MyUtx() { }
}Ins;
While, I always get below link error for module B:
Undefined symbols for architecture x86_x64:
"typeinfo for utx", referenced from:
typeinfo for MyUtx in main.o
If the utx's destructor is non-virtual, the problem goes away.
Have you tried:
class __attribute__ ((visibility("default"))) utx
{
...
According to http://gcc.gnu.org/wiki/Visibility typeinfo generation depends on whether your class has vfptr and adding virtual destructor can change that (if you have no other virtual functions).