PDA

View Full Version : Application Plugins in Windows [XP]



dcurtis
8th February 2007, 00:26
First off, i have no problem in Linux with this stuff running.

Now the background, I have developed an app that loads plugins from the 'plugins' directory of my applications exe directory in windows. It works fine on the development machine, and also on another Windows XP running SP1. However, i have another machine setup running a fresh windows installation. Fresh install with nothing done to it. I have all the necessary .dll files (QtCore4.dll QtGui4.dll, msvcr80.dll, etc.) in the .exe directory (app directory). There is no problem running the program. It's that the dynamically loaded plugins will NOT load.

Even more info: when i changed my code to not look in "./plugins" but actually look in "./" and moved the .dll files to that directory, they loaded. But this makes no sense to me.

Now, i've looked EVERYWHERE for a solution to this and i cannot find anything. No one seems to have had this problem which i find hard to believe. I have read as much as i can from the msdn library but it's just so boring and nothing there seems to help.

I can rule out a few things: It's not my app. You can reproduce this behavior with the plugandpaint app. It also will NOT load the plugins from the "plugins" directory.

Raw Problem: Plugins will not load when in a subdirectory of the main exe and dependency dll's.

Reproducing: Just use a fresh install of windows w/out QT4 and copy over the plugandpaint app which you compiled on another windows machine.

Frustrating the crap out of me. Please let me know what's up.

jacek
8th February 2007, 00:30
Try creating a "qt.conf" file (in the same directory where your executable) is with following contents:
[Paths]
Plugins = plugins

dcurtis
8th February 2007, 00:39
Try creating a "qt.conf" file (in the same directory where your executable) is with following contents:

This did not fix the problem. I believe this file is used for loading of QtPlugins (ie. plugins that are built into QT). Either way that doesn't seem to be the problem.

Thanks for the reply. Much appreciated.

I'm going to try to install the dotNet framework and see if this fixes the problem at least. It'd be at least better than not knowing what is missing on a system for this to not work. I don't get why SP1 and SP2 seem to fix the problem. And how can i distribute this app.

croland
8th February 2007, 02:59
I had the same problem on Windows when using the qsqlite.dll sqldrivers plugin. I was able to resolve the issue by using the following qt.conf:

[Paths]
Prefix = ./
Plugins = plugins

Also the folder structure was:

ExeDirectory\
ExeDirectory\plugins
ExeDirectory\plugins\sqldrivers

qsqlite.dll was located at:
ExeDirectory\plugins\sqldrivers\qsqlite.dll

qt.conf was located at:
ExeDirectory\qt.conf

Figured I would throw my two cents in.

dcurtis
8th February 2007, 04:16
I tried adding the prefix line but still no luck.

Thanks again for the reply.

ChristianEhrlicher
8th February 2007, 05:09
I tried out plugandpaint example and everything works fine.
Did you output some debug messages in MainWindow::loadPlugins() (don't forget CONFIG +=console)?
Do you use VS2005 -> did you also copy the .manifest files?
Take a look into the registry (regedit) under HKCU\Software\Trolltech\Qt Plugin Cache 4.2\ (or Qt Plugin Cache 4.2.debug for debug) to see if your plugins are found and if they've the correct build key.

The plugandpaint example loads the plugins manually so it should be easy to see if they're found by modifiyng MainWindow::loadPlugins().

dcurtis
8th February 2007, 06:16
Yes, i am using vc2005.

I am also manually loading plugins from my Main app. I don't believe this is the same problem.

Thanks for the reply though.

ChristianEhrlicher
8th February 2007, 06:34
So why don't you try out to debug it as I mentioned?

dcurtis
8th February 2007, 06:43
So why don't you try out to debug it as I mentioned?

i already did with my own app.. i know they are being found because with the same directory structure on another machine they work.

ChristianEhrlicher
8th February 2007, 06:50
So the only problem I can think of is a problem with the manifests / side by side assemblies. The goal was to simplify the dll hell with those crap, but ...
Try to load the dll with QLibrary and see if it works - when it works, the manifest shouldn't be the problem.

dcurtis
9th February 2007, 03:01
So the only problem I can think of is a problem with the manifests / side by side assemblies. The goal was to simplify the dll hell with those crap, but ...
Try to load the dll with QLibrary and see if it works - when it works, the manifest shouldn't be the problem.

Well, i've debugged the problem and here it is;

in vs2005, it automatically embeds the manifest into the .dll / .exe file. For some reason if you do embed the manifest into a plugin dll, it will NOT load. I don't know why but that is the problem. I recompiled all my plugins without the manifest and they run fine. I'm going to attempt to use the command line tools to embed the manifest and see if there is the same problem just for my own curiosity. Thanks for all your replies. Thanks cmake! Really i love it but damn, what a bug.


/edit: also, if you embed the manifest into the plugin dll using mt.exe (rather than letting VS2005 do it for you, it does not cause a problem!) What the heck MS...