PDA

View Full Version : QMainWindow in a lib and dlopen/dlsym: RTTI symbol not found for class 'QWidget'



NullPointer
26th July 2011, 01:57
Hello there,

I'm getting an "RTTI symbol not found for class 'QWidget'" (Debug) or a Segmentation fault (direct run) when running an application that makes an dlopen and an dlsym.

In my library I have this:


# define MHD(retType) extern "C" retType __attribute__((visibility("default")))
MHD(QMainWindow *) newWindow(QWidget * parent){
return new MainWindow(parent); //MainWindow is a QMainWindow subclass
}


And in my application I have:

typedef QMainWindow* (*newWindow_t)(QWidget*);
void * dso=dlopen("libMHD.so", RTLD_NOW | RTLD_GLOBAL);
nw=(newWindow_t)dlsym(dso, "newWindow");
QMainWindow* mw=nw(this);
mw->show();

With both projects open in QtCreator I am able to debug, and reach the constructor of MainWindow, then stepping into, I fall in a QFlag definition, then SIGSEGV... :(

I need this to make an application open plugins... The idea is to have a function in each library that returns an std::vector containing all wrappers (I have a base class, and this one have a method const char* getKey(), so I can call a Factory to create new instances of each class using a string.).

This is my first step, and I can't proceed...

So, why, even with QT+= core gui, I'm getting such error?

(Sorry English mistakes...)

Thanks in advance.

NullPointer
26th July 2011, 04:09
Aha!

The problem is with the shadow build...
I tried doing a qmake; make from konsole and everything works :D

(I'm feeling little trolled by QtCreator... :P )