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

Guido Seifert Wargand at gmx.de
Tue Dec 15 18:12:36 CET 2009



> .... at a stage where some other (Tcl/Tk?) event loop is already
> running (and has possibly already aquired resources which "Qt" 
> wants to use exlusively maybe, etc. etc.)

No, no other event loop running. Tcl was the original program, which I rewrote in Qt.


> A "plugin" is nothing else than an ordinary shared library 
> (*.dll, *.so, *.dynlib, ...), additionally with some "well-known" 
> create/delete functions (C style!) which can be "dllopened" 

Unfortunalely no. After I failed to convert the whole program into a lib, I tried just out of curiosity to load a qt plugin, which works fine when I load it with the QPluginLoader, with dlopen. Same segfault.

> You on the other hand try to initialise the entire Qt 
> "resource system", by calling Q(Core)Application in a plugin, which > is loaded by a completely (non-Qt) "host application". This is very > different from the above!

It was worth a try. And I don't really see the difference whether QApplication is called in main or in any other function. Even if this function is 'outsourced' into some lib. Nevertheless, this question is moot, since QApplication is never executed.

>I would proof your approach first with a simple "Hello World" Qt app, 
> e.g. with the link I provided previously.

I tried even simpler that that. An empty 'main' function. As soon as QMake adds Qt functionality I have the crash. When a dynlib is loaded all sorts of global static initialisations are done. Long before the main functions is called.  The core file tells me it is somewhere in QCoreApplication and there somewhere in one of the mutex classes. 

So I alredy suspected that what I want to do is impossible. Just hoped someone had an idea for a workaround. :-)


-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01



More information about the Qt-interest-old mailing list