June 24, 2011

frinker frinker
Lab Rat
10 posts

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

Page  
1

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.

17 replies

June 24, 2011

Volker Volker
Ant Farmer
5428 posts

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.

June 24, 2011

Gerolf Gerolf
Hobby Entomologist
3287 posts

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

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

June 24, 2011

loladiro loladiro
Lab Rat
596 posts

@Gerolf It’s a windows thing (example [codeproject.com])

June 24, 2011

Volker Volker
Ant Farmer
5428 posts
loladiro wrote:
@Gerolf It’s a windows thing (example [codeproject.com])

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

June 24, 2011

loladiro loladiro
Lab Rat
596 posts
Volker wrote:
loladiro wrote:
@Gerolf It’s a windows thing (example [codeproject.com])

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

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/yx1×886y(v=vs.71).aspx

  1. 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.

June 24, 2011

Volker Volker
Ant Farmer
5428 posts
loladiro wrote:
Volker wrote:
loladiro wrote:
@Gerolf It’s a windows thing (example [codeproject.com])

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

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/yx1×886y(v=vs.71).aspx

  1. 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.

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.

June 24, 2011

loladiro loladiro
Lab Rat
596 posts

I’m not the OP

EDIT: And I actually wouldn’t use delay loading

June 24, 2011

Volker Volker
Ant Farmer
5428 posts

loladiro wrote:
I’m not the OP

EDIT: And I actually wouldn’t use delay loading

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

June 24, 2011

loladiro loladiro
Lab Rat
596 posts

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

June 24, 2011

frinker frinker
Lab Rat
10 posts

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’

June 24, 2011

Gerolf Gerolf
Hobby Entomologist
3287 posts

if you read MSND on that, it states:

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

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

June 24, 2011

frinker frinker
Lab Rat
10 posts

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?

June 24, 2011

loladiro loladiro
Lab Rat
596 posts

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.

June 24, 2011

Gerolf Gerolf
Hobby Entomologist
3287 posts

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.

frinker wrote:
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…

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

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

June 24, 2011

cincirin cincirin
Ant Farmer
467 posts

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 [alienskin.com] use Qt in their plug-in development, and Qt dependent libraries are not in system32 or whatever known search path.

Page  
1

  ‹‹ header file reference problem???      [SOLVED]QMAKE - debug/release directory ››

You must log in to post a reply. Not a member yet? Register here!