Is it possible to delay load QtGui4.dll in Windows?



  • Hi,

    I have an application which has to delay load the Qt libraries. The application contains several Qt dialog. I can successfully delay-load QtCore, but when I was trying to delay-load the QtGui, it failed with LNK1194.
    _
    _LINK : fatal error LNK1194: cannot delay-load 'QtGuid4.dll' due to import of data symbol '"__declspec(dllimport) public: static struct QMetaObject const QDialog::staticMetaObject" (_imp?staticMetaObject@QDialog@@2UQMetaObject@@B)'; link without /DELAYLOAD:QtGuid4.dll
    _

    it seems like the static variable caused the problem. So is it possible to delay load QtGui4.dll? And how?

    Thanks,

    D.J.



  • You need QApplication before even constructing a QWidget based object. As QApplication is located in QtGui4.dll it will be loaded immediately after starting your program. So why delay-load it? I see no sense in that.



  • and QtCore will be loaded by QtGui, so what do you mean by delay loading? Load via LoadLibrary?





  • [quote author="loladiro" date="1308906058"]@Gerolf It's a windows thing ("example":http://www.codeproject.com/KB/DLL/Delay_Loading_Dll.aspx)[/quote]

    That does not answer any questions you've been asked.



  • [quote author="Volker" date="1308906327"]
    [quote author="loladiro" date="1308906058"]@Gerolf It's a windows thing ("example":http://www.codeproject.com/KB/DLL/Delay_Loading_Dll.aspx)[/quote]

    That does not answer any questions you've been asked.[/quote]

    True, but I was pointing out what delay loading is (not everybody necessarily knows that. But to answer the question:
    http://msdn.microsoft.com/en-us/library/yx1x886y(v=vs.71).aspx
    [quote]

    Imports of data cannot be supported. A workaround is to explicitly handle the data import yourself using LoadLibrary (or GetModuleHandle after you know the delay-load helper has loaded the DLL) and GetProcAddress.

    [/quote]



  • [quote author="loladiro" date="1308906878"][quote author="Volker" date="1308906327"]
    [quote author="loladiro" date="1308906058"]@Gerolf It's a windows thing ("example":http://www.codeproject.com/KB/DLL/Delay_Loading_Dll.aspx)[/quote]

    That does not answer any questions you've been asked.[/quote]

    True, but I was pointing out what delay loading is (not everybody necessarily knows that. But to answer the question:
    http://msdn.microsoft.com/en-us/library/yx1x886y(v=vs.71).aspx
    [quote]

    Imports of data cannot be supported. A workaround is to explicitly handle the data import yourself using LoadLibrary (or GetModuleHandle after you know the delay-load helper has loaded the DLL) and GetProcAddress.

    [/quote][/quote]

    Thanks. I know how to use google to know what delay loading is.

    That still does not answer the question why you want or need it in your application.



  • I'm not the OP

    EDIT: And I actually wouldn't use delay loading



  • [quote author="loladiro" date="1308907102"]I'm not the OP

    EDIT: And I actually wouldn't use delay loading[/quote]

    Oops. I'm very sorry, I totally misread this :-( Please accept my apologies.



  • No problem :). Now I understand at least why you said it ;)



  • Thank you guys, I'm sorry I didn't say it clearly. The application is a plugin for Photoshop. And it seems that Photoshop wouldn't have the plugin folder included in the dll search path. (see my question in the ps forum http://forums.adobe.com/message/3759318#3759318). That's why I have to delay load the qt libraries - I want to have a chance to call 'SetDllDirectory' to find the qt libraries.

    I guess it's the import data problem. But the thing is my dialog is generated by .ui (uic, moc..), and I have no explicit reference to 'QDialog::staticMetaObject'



  • if you read MSND on that, it states:

    bq. You should consider delay loading a DLL if:

    • Your program may not call a function in the DLL.
    • A function in the DLL may not get called until late in your program's execution.

    As you typically have QtCore/QtGui components really early in main, I think it makes definitely no sense to delay load Qt libs, especially QtCore and QtGui



  • As I said, I have to delay load, because of the limitation of Photoshop (actually we have a feature request for them). Otherwise, I have to change system 'PATH' or 'app path' in registry to tell windows where to find Qt, or write another wrapper for my plugin, which would be ugly...

    So let's back to the question, how can I delay load qt libraries if my Dll contains both the code of QApplication and QDialog?



  • Well, you could put the Qt libraries into the proper search path (if you don't want to copy your dll, you could have a look at "known dlls"). All versions new of Qt are binary compatible to older ones (within a major release e.g. Qt4), so their shouldn't be a problem with other programs using Qt either.



  • But the point is, you can't compile, right?
    If the compiler does not allow delayload, I think, you can't delay load it, sorry.

    [quote author="frinker" date="1308909013"]As I said, I have to delay load, because of the limitation of Photoshop (actually we have a feature request for them). Otherwise, I have to change system 'PATH' or 'app path' in registry to tell windows where to find Qt, or write another wrapper for my plugin, which would be ugly...
    [/quote]

    By the way, before, you did not say why you need it before, you just said, you want.



  • I personally would prefer a plug-in proxy wrapper. I do not think it's so hard to change code : leave in main plugin just Photoshop calling function (advanceState, aquireSuite, etc.) and they will communicate dynamically with Qt proxy wrapper. However I know that "Alien Skin":http://www.alienskin.com/ use Qt in their plug-in development, and Qt dependent libraries are not in system32 or whatever known search path.



  • We have a similar problem with an Adobe InDesign plugin. We just make an installer for the plugin and put the Qt DLLs into the InDesign application folder (we get the path from some registry entries). That's in the search path and we never needed any tricky stuff like delay loading.



  • Thanks guys, I would like to write a proxy to wrap my plugin. I think it would be the easiest way to solve my problem.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.