[Qt-interest] Making a Qt program into a dynamic library
Oliver.Knoll at comit.ch
Oliver.Knoll at comit.ch
Tue Dec 15 18:01:22 CET 2009
Guido Seifert wrote on Tuesday, December 15, 2009 5:44 PM:
> > ...
> int start(int argc, char *argv[]){
> return 1;
> }
>
> It is enough to have a CONFIG += qt in my .pro file to trigger the
> crash. It must happen while the lib is being loaded. Long before it
> even comes close to my code.
Okay, that sound like that when linking with your plugin (which on its turn then links with Qt) that some "static initialisation code" is automatically executed, as soon as the Qt library (QtCore etc.) is loaded.
I have never used these features for my own libraries, but at least on Windows I am sure that one can specify certain (init) functions, which are automatically executed (by the dynamic linker probably) as soon as the DLL gets loaded into memory.
If this is the case then it means bad luck, since as you say, that happens long before your own code is called, so there is (probably) nothing you can do about it.
(Your and my next question will probably then be: "Why does it work then with Qt based plugins, together with Qt apps?" - The answer is probably that since with normal Qt based applications QtCore etc. is already loaded into memory, so the initialisation doesn't happen twice... or so. Does that make sense?)
The only thing is that you could try to tweak Qt with some configure switches and try to get rid of this "automatic Qt initialisation" (which for now we suspect is the culprit).
By the way, another insightful experiment could be if you try to dlopen a plugin which has been compiled with:
CONFIG += QtCore
CONFIG -= QtGui
(that is, no GUI parts). Would that work? (If yes, then you would pinpoint the problem into the "GUI part" of Qt. Okay, for you that would probably make no difference, since you need the UI part, but anyway...)
Cheers, Oliver
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22
More information about the Qt-interest-old
mailing list