PDA

View Full Version : DLLs not found when testing in other PC



Mobility
20th March 2013, 07:14
Hi,

My application is somewhat ready to be tested wider so I have build it with release target, and it seem to work fine in the PC I've used for developing it. However I'm not able to get it working in another PC.

I'm getting errors that not all DLLs are found. To be specific, SQL DLLs are not found. At first it did not find any SQL drivers (even though they were located under /sqldrivers folder in the app directory). Then I found out that it was trying to search then from plugins directory, which is C:\QtSDK\Desktop\Qt\4.8.0\mingw\plugins by default, hence it created that directory and placed the sqldrivers there - just like in the development PC.

Unfortunately even this did not work. All the other drivers were found but not the PSQL driver which is needed. Currently I've got all the DLLs (yes, the same DLLs in every folder) in the mentioned plugins directory, App directory and App/sqldrivers directory. The first problem is that it does not find any of those sql drivers if not located at the plugins directory, why? The second problem is that even if the plugins directory is created, still QPSQL driver is not working - any idea why is that? I would think I have all the DLLs created because it's working on the development PC.

Cheers!

UPDATE:
I tried to run dependency walker on target PC and it gives following:

LoadLibraryW("C:\QtSDK\Desktop\Qt\4.8.0\mingw\plugins\sqldrivers \qsqlpsql.dll") returned NULL. Error: %1 is not a valid Win32 application (193).

Both PCs (one used for developing and this target PC) are running 64 bit Windows7, but during the process I have used 32bit tools. Cannot understand the error message...

Santosh Reddy
20th March 2013, 10:14
<app-dir>/sqldrivers/qsqlpsql.dll
Make sure the dll exists in this path on the target PC. Where <app-dir> is the directory which contains the application executable (.exe) file.

Mobility
20th March 2013, 11:19
Thanks, but as I said I've already got all the DLLs (including qsqlpsql.dll) in three different folder, just to be sure.

<app-dir>\
<app-dir>\sqldrivers\
C:\QtSDK\Desktop\Qt\4.8.0\mingw\plugins\sqldrivers \

Still it's not working. To get it working even from the plugin path, I would need to understand why following error is seen in DependencyWalker:

LoadLibraryW("C:\QtSDK\Desktop\Qt\4.8.0\mingw\plug ins\sqldrivers\qsqlpsql.dll") returned NULL. Error: %1 is not a valid Win32 application (193).

UPDATE:

To my understanding the error means that it can be executed only in x86 machine. Why on earth it's working on the other PC which has also Win7 64bit? And as I said, every tool I have used has been 32bit version (QtSdk, QtCreator, OpenSSL, PSQL ...). Why this error pops up now with one DLL and just in another PC?

amleto
21st March 2013, 00:50
http://stackoverflow.com/questions/11305633/xxxxxx-exe-is-not-a-valid-win32-application

Mobility
22nd March 2013, 08:57
Thanks. Not sure if I got it right but isn't that thread talking about Visual Studio, which I'm not using? I'm using Qt Creator and Mingw, so I understand that the thread is not applicable for my case? To be noticed also that my .exe file is working, but the earlier mentioned PSQL dll is giving the error.

ChrisW67
23rd March 2013, 00:26
Did you deploy a 32bit PostgreSql run time library? Thq Qt PSQL plugin depends on that being present. Load the Qt plugin into Dependcy Walker to check.

Mobility
24th March 2013, 17:30
Hmm... I'm sorry but I have to admit that I don't fully understand what do you mean. By PSQL run time library you mean qsqlpsql.dll? That is giving the error:

LoadLibraryW("C:\QtSDK\Desktop\Qt\4.8.0\mingw\plug ins\sqldrivers\qsqlpsql.dll") returned NULL. Error: %1 is not a valid Win32 application (193).

So far I have just checked my .exe file in Dependency Walker. Which file (= referred Qt plugin) do you suggest to check?

Thanks for you time!

UPDATE:

I checked the qsqlpsql.dll with dependency walker and found out that openssl related dlls were x64. Also after debugging a while I found out that one postgresql dll (libintl.dll) was missing too. Anyway now the driver is found and the connection succeeds. Thank you very much!

So one problem solved and one to go. The remaining problem is that DLLs are just found from the plugin directory and if located only in my application directory, the app wont work.

Mobility
8th April 2013, 16:13
I still got the problem not finding the sql libs from the plugin directory. I tried tracing the plugin and library paths with following results:

plugin path: C:\QtSDK\Desktop\Qt\4.8.0\mingw\plugins
lib paths: C:/Program Files (x86)/App/plugins, C:/QtSDK/Desktop/Qt/4.8.0/mingw/plugins, C:/Program Files (x86)/App

So it seems that the application folder ("App") is listed in lib paths as well as the plugins path. For some reason that is not enough and the actual plugin path refers to a folder in the develop-PC. How can I get the sql plugins work somewhere under the application path?

It seems to find all the drivers and I'm able to trace them:

QSQLITE, QODBC3, QODBC, QPSQL7, QPSQL

but when trying to open a DB it gives error: Driver not loaded

Edit.
In addition it does not make it easier that dependency walker always jams if the App is profiled from installation directory - it only works when profiled from "release" directory.

FINAL EDIT - SOLVED

I added plugins path as follows and got it working:


int main(int argc, char *argv[])
{
QApplication a(argc, argv);
a.addLibraryPath(QCoreApplication::applicationDirP ath()+"/plugins");
MainWindow w;
w.show();

return a.exec();
}

Also my problem with SQL driver was that I initialized it in global are, which was wrong. See thread: http://www.qtcentre.org/threads/43928-App-found-qsqlite4-dll-driver-file-but-still-quot-Driver-not-loaded-quot

ChrisW67
8th April 2013, 23:56
If you had deployed the Qt plugins into the expected location then you would not have needed to do this. Santosh Reddy told you where that was for the SQL drivers, you told us you had put them there, but clearly you had not.

ospica52
27th August 2015, 19:03
SOLVED
I developed an app wich enviroment looks like you said: Win x64 but tools x32 and I had the same problem, however the solution was to add msvcr120.dll to the app_dir/

I hope it helps :)