[Qt-interest] Making a Qt program into a dynamic library

Guido Seifert Wargand at gmx.de
Wed Dec 16 10:36:06 CET 2009


 
> It seems that upon initialisation of Qt - once the shared library gets
> loaded - fails, for whatever reasons. Before the path of execution 
> reaches a single line of the OP's own code (linking with CONFIG += 
> Qt alone is apparently enough to even make a single printf("Hello 
> World!"); fail)
 
True. Below is a backtrace of a segfault. As it can be seen, it happens in QtCore. The program which caused this crash:

int main(int argc, char *argv[])
{
  void* handle = dlopen("./mylib.so", RTLD_LAZY);
  return 1;
}

mylib.so = Qt plugin.


All this is a bit sad and I wonder if Nokia is aware of this problem or even sees this as problem. I could understand it when a QApplication event loop fails to be used this way. But the way it seems to be, is that it is generally impossible to write shared libraries using Qt, which are not used in a Qt environment, i.e. not even a simple QString can be used.


The dump:

#0  0x3669e8f8 in ?? ()
#1  0xb65e393c in QReadWriteLock::lockForWrite (this=0x8050788) at thread/qmutex.h:120
#2  0xb6662c60 in QAbstractFileEngineHandler (this=0x8050778)
    at ../../include/QtCore/../../src/corelib/thread/qreadwritelock.h:158
#3  0xb66963c7 in resource_file_handler () at io/qresource.cpp:1189
#4  0xb6696477 in global constructors keyed to qresource.cpp () at io/qresource.cpp:1505
#5  0xb675670d in __do_global_ctors_aux () from /usr/local/Trolltech/Qt-4.6.0/lib/libQtCore.so.4
#6  0xb65c35d0 in _init () from /usr/local/Trolltech/Qt-4.6.0/lib/libQtCore.so.4
#7  0xb80091e4 in ?? () from /lib/ld-linux.so.2
#8  0xb8009314 in ?? () from /lib/ld-linux.so.2
#9  0xb800d27b in ?? () from /lib/ld-linux.so.2
#10 0xb8008e26 in ?? () from /lib/ld-linux.so.2
#11 0xb800ca2c in ?? () from /lib/ld-linux.so.2
#12 0xb7507c0f in ?? () from /lib/libdl.so.2
#13 0xb8008e26 in ?? () from /lib/ld-linux.so.2
#14 0xb75080dc in ?? () from /lib/libdl.so.2
#15 0xb7507b41 in dlopen () from /lib/libdl.so.2
#16 0x080489ff in main () at main.cpp:28



-- 
Jetzt kostenlos herunterladen: Internet Explorer 8 und Mozilla Firefox 3.5 -
sicherer, schneller und einfacher! http://portal.gmx.net/de/go/chbrowser



More information about the Qt-interest-old mailing list