Trouble linking custom widgets between different libraries
-
Hi all,
I'm trying to build up a system where a core library defines system-wide widgets, and various project libraries define project-specific widgets. The project-specific widgets inherit from the system-wide widgets. So it looks something like this:
compiled into system_widgets.so:
@
class OcuWidget : public QWidget
{
Q_OBJECT
//etc
};
@compiled into myproject_widgets.so:
@
class MyProjectWidget : public OcuWidget
{
Q_OBJECT
//etc
};
@I compile all of this against qt 4.5.2 and the system widgets work just fine. As soon as I try to load the project widgets, though, I get a segfault in qt:
@
Program received signal SIGSEGV, Segmentation fault.
0x010f7f51 in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
from /usr/lib/libQtGui.so.4
(gdb)
(gdb) bt
#0 0x010f7f51 in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
from /usr/lib/libQtGui.so.4
#1 0x010ff5ca in QApplication::notify(QObject*, QEvent*) ()
from /usr/lib/libQtGui.so.4
#2 0x01bf36cb in QCoreApplication::notifyInternal(QObject*, QEvent*) ()
from /usr/lib/libQtCore.so.4
#3 0x01bf42b2 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from /usr/lib/libQtCore.so.4
#4 0x01bf447d in QCoreApplication::sendPostedEvents(QObject*, int) ()
from /usr/lib/libQtCore.so.4
#5 0x01c1e3ff in ?? () from /usr/lib/libQtCore.so.4
#6 0x02404e88 in g_main_context_dispatch () from /lib/libglib-2.0.so.0
#7 0x02408730 in ?? () from /lib/libglib-2.0.so.0
#8 0x02408863 in g_main_context_iteration () from /lib/libglib-2.0.so.0
#9 0x01c1e02c in QEventDispatcherGlib::processEvents(QFlagsQEventLoop::ProcessEventsFlag) () from /usr/lib/libQtCore.so.4
#10 0x01198be5 in ?? () from /usr/lib/libQtGui.so.4
#11 0x01bf1c79 in QEventLoop::processEvents(QFlagsQEventLoop::ProcessEventsFlag) () from /usr/lib/libQtCore.so.4
#12 0x01bf20ca in QEventLoop::exec(QFlagsQEventLoop::ProcessEventsFlag) ()
from /usr/lib/libQtCore.so.4
#13 0x01bf453f in QCoreApplication::exec() () from /usr/lib/libQtCore.so.4
#14 0x010f7dd7 in QApplication::exec() () from /usr/lib/libQtGui.so.4
---Type <return> to continue, or q <return> to quit---
#15 0x08049502 in main (argc=1, argv=0xbfffeda4)
at /home/re2/ros/stacks/re2ocu/re2_ocu/src/nodes/ocu.cpp:11
(gdb)
@I know that qt does some fancy stuff with building up its own symbols through preprocessing and such, so is there something about linking between different .so's that would cause this to happen, or is there some other issue here I'm not seeing?
-
Well, you built it, so I suppose you set LIBS correctly.
I can't say what can be wrong with the information you provided as it seems correct and the backtrace is not conclusive.
Can you reproduce this problem with a simpler test case? Let's see if we can isolate the problem.
-
I made a simple test of your scenario, to make sure if it would require any non standard step:
AWidget, which inherits QWidget, is part of liba.
BWidget inherits from AWidget and is part of libb.
A dummy main.cpp where QApplication is initialized and a BWidget is created and shown.The BWidget showed up on the screen normally, without any non expected action to build the whole thing.
So, check if there is a bug in your lib, even though the segmentation fault happens inside Qt, it can be triggered by a wrong line in your code. If you find a suspect, post a snipet here so we can help you.