PDA

View Full Version : Unsual Runtime Termination



ShamusVW
17th November 2009, 10:19
I have written a program to connect to mySQL database. When I transfer the executable to the machine that will run the application, I get an error


Runtime error
This application has caused the runtime to terminate it in an unusual way...
Contact...

I have copied a number of the dlls over, hoping to strike lucky, but alas!:(

The ones copied:
libmysql.dll
qsqlmysql4.dll
qsqlmysqld4.dll
Qtsqld4.dll
QtNetworkd4.dll
QtCored4.dll
QtGuid4.dll
Mingwm10.dll

Can someone help me please?
Thanks.

ShamusVW
18th November 2009, 07:05
Can someone not write a batch file to or similar to create this plugin? (one file, no arguments)

Also, why can the file needed not just be downloaded, why does each person have to build the plugin independently?

schnitzel
18th November 2009, 20:59
generally, people want to see some sample code. You will get much quicker help that way.

I can guess what your issue is by looking at how you listed your dll's.
qsqlmysql4.dll and qsqlmysql4d.dll should go into a subfolder 'sqldrivers', according to this guide:

http://doc.trolltech.com/4.5/deployment-windows.html#qt-plugins

Look at the first paragraph.

hope this helps

schnitzel
19th November 2009, 16:22
generally, people want to see some sample code. You will get much quicker help that way.

I don't know what I was thinking :o ... ignore that line. Your issue is clearly a deployment problem, not source code related.

The rest of my post should still apply though.

ShamusVW
29th January 2010, 10:49
Thanks for the previous help. Unfortunately it didn't work.
Because I previously did a work-around using Delphi, I had actually put this aside, but now I have to get it working, since I am trying to get 2 different programs to do the job that one should do, and C++/Qt is the way I want to do it.

I looked at that deployment document that was mentioned, and then made the directory "sqldrivers" under the directory that my application resides in. I get the same error message. I then also tried renaming the directory to "plugins" (also what I read in that document), but alas, no joy. Then I looked at the standard install of qt's directory, and saw that "sqldrivers" is under "plugins". I tried this where my application sits, i.e.made a new directory under plugins, and moved qsqlmysql4.dll into it (release compilation), but still just the error message.

Just to say, on the development machine it runs fine. Even if I move it to a testing directory on my own computer, but I DON'T have this sqldrivers/plugins directory in the testing directory, and I also don't have qsqlmysql4.dll in the directory, it still runs fine and connects to my MySQL database. It obviously has a default lookup directory where this plugin is stored (I'm assuming this, but then why doesn't it find all the other dll's, like QGUi and QCore etc if these aren't in the application directory?)

I have installed the latest Qt (4.6) and Qt Creator using the SDK binary. However, to build my plugin I did the following:


Added C:\Qt\2010.01\mingw\bin & C:\Qt\2010.01\qt\bin to my Windows path. Wasn't there before
C:\>set QTDIR=c:\Qt\2010.01\qt ****Wasn't automatically done when Qt/Creator initially installed
C:\>set QMAKESPEC=c:\Qt\2010.01\qt\mkspecs\win32-g++ ****Wasn't automatically done when Qt/Creator initially installed
C:\>cd %QTDIR% ****Wasn't automatically done when Qt/Creator initially installed
C:\Qt\2010.01\qt>configure -plugin-sql-mysql -I C:\mysql\include
Which edition of Qt do you want to use ?
Type 'c' if you want to use the Commercial Edition.
Type 'o' if you want to use the Open Source Edition.
o

This is the Qt for Windows Open Source Edition.

You are licensed to use this software under the terms of
the GNU Lesser General Public License (LGPL) version 2.1
or the GNU General Public License (GPL) version 3.

Type '3' to view the GNU General Public License version 3 (GPLv3).
Type 'L' to view the Lesser GNU General Public License version 2.1 (LGPLv2.1).
Type 'y' to accept this license offer.
Type 'n' to decline this license offer.

Do you accept the terms of the license?
y
All the required DirectShow/Direct3D files couldn't be found.
Make sure you have either the platform SDK AND the DirectShow SDK or the Windows
SDK installed.
If you have the DirectShow SDK installed, please make sure that you have run the
<path to SDK>\SetEnv.Cmd script.
vmr9.h not found
dshow.h not found
strmiids.lib not found
dmoguids.lib not found
msdmo.lib not found
d3d9.h not found
Environment:
INCLUDE=
Unset
LIB=
Unset
PATH=
C:\Program Files\Common Files\Microsoft Shared\Windows Live
C:\Documents and Settings\svanwyngaard\My Documents\Borland Studio Project
s\Bpl
C:\Program Files\ESTsoft\ALZip\
C:\Program Files\Nmap

c:\windows
c:\windows\system32
C:\Program Files\Common Files\Autodesk Shared
C:\PTC\proeWildfire 3.0\bin
C:\PTC\flexnet\bin
c:\windows\System32\wbem
C:\mysql\bin
C:\WINDOWS\system32\WindowsPowerShell\v1.0
C:\Program Files\Common Files\Microsoft Shared\Windows Live
C:\Documents and Settings\svanwyngaard\My Documents\Borland Studio Project
s\Bpl
C:\Program Files\ESTsoft\ALZip\
C:\Program Files\Nmap
C:\Qt\2009.04\qt\bin
C:\Qt\2009.04\mingw\bin
C:\mysql\bin
You are licensed to use this software under the terms of the GNU GPL version 3.Y
ou are licensed to use this software under the terms of the Lesser GNU LGPL vers
ion 2.1.
See C:/Qt/2010.01/qt3

or C:/Qt/2010.01/qtL

Configuration:
minimal-config
small-config
medium-config
large-config
full-config
build_all
debug
Qt Configuration:
release
debug
zlib
png
accessibility
qt3support
opengl
s60
ipv6
script
scripttools
xmlpatterns
multimedia
multimedia
audio-backend
webkit
native-gestures
svg
minimal-config
small-config
medium-config
large-config
full-config

QMAKESPEC...................win32-g++ (env)
Architecture................windows
Maketool....................mingw32-make
Debug symbols...............yes
Link Time Code Generation...no
Accessibility support.......yes
STL support.................yes
Exception support...........yes
RTTI support................yes
MMX support.................no
3DNOW support...............no
SSE support.................no
SSE2 support................no
IWMMXT support..............no
OpenGL support..............yes
OpenVG support..............no
OpenSSL support.............no
QtDBus support..............no
QtXmlPatterns support.......yes
Phonon support..............no
QtMultimedia support........yes
WebKit support..............yes
Declarative support.........no
QtScript support............yes
QtScriptTools support.......yes
Graphics System.............raster
Qt3 compatibility...........yes

Third Party Libraries:
ZLIB support............qt
GIF support.............plugin
TIFF support............plugin
JPEG support............plugin
PNG support.............qt
MNG support.............plugin
FreeType support........no

Styles:
Windows.................yes
Windows XP..............no
Windows Vista...........no
Plastique...............yes
Cleanlooks..............yes
Motif...................yes
CDE.....................yes
Windows CE..............no
Windows Mobile..........no
S60.....................no

Sql Drivers:
ODBC....................no
MySQL...................yes
OCI.....................no
PostgreSQL..............no
TDS.....................no
DB2.....................no
SQLite..................plugin (qt)
SQLite2.................no
InterBase...............no

Sources are in..............C:\Qt\2010.01\qt
Build is done in............C:\Qt\2010.01\qt
Install prefix..............C:\Qt\2010.01\qt
Headers installed to........C:/Qt/2010.01/qt/include
Libraries installed to......C:/Qt/2010.01/qt/lib
Plugins installed to........C:/Qt/2010.01/qt/plugins
Binaries installed to.......C:/Qt/2010.01/qt/bin
Docs installed to...........C:/Qt/2010.01/qt/doc
Data installed to...........C:/Qt/2010.01/qt
Translations installed to...C:/Qt/2010.01/qt/translations
Examples installed to.......C:/Qt/2010.01/qt/examples
Demos installed to..........C:/Qt/2010.01/qt/demos

[A whole lot of output...]


C:\Qt\2010.01\qt>cd %QTDIR%\src\plugins\sqldrivers\mysql
C:\Qt\2010.01\qt\src\plugins\sqldrivers\mysql>qmake "INCLUDEPATH+=C:\MySQL\include" "LIBS+=C:\mysql\lib\opt\libmysql.lib" mysql.pro


[3 MakeFile's get generated under C:\Qt\2010.01\qt\src\plugins\sqldrivers\mysql]


C:\Qt\2010.01\qt\src\plugins\sqldrivers\mysql>mingw32-make
Under c:\Qt\2010.01\qt\plugins\sqldrivers 4 files have been created
libqsqlmysql4.a & libqsqlmysqld4.a
qsqlmysql4.dll & qsqlmysqld4.dll

I have the following code:


QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("****");
db.setDatabaseName("****");
db.setUserName("****");
db.setPassword("****");
if (!db.open()) {
qDebug() << db.lastError();
}
else {
qDebug() << "Successfully connected to mySQL DB";
}

I get a successful connect with this on development machine, just a runtime-crash on the deployment computer.
Please help!:confused:

ShamusVW
2nd February 2010, 10:12
Please can someone advise me on this?
I am currently rebuilding as static release to try it tis way, but not ideal.
I am SO close, it just has to get round the run-time error.
...PLEASE...

schnitzel
2nd February 2010, 18:41
also as of recently, you have to deploy libgcc_s_dw2-1.dll
is the client mysql dll (libmysql.dll) in your path?

if that doesn't work, please try to run depends.exe on your app to see what else could be missing.

I noticed in the output from configure that there is a reference to a previous version of Qt, perhaps that's where your problem lies. Try un-installing all the versions and then re-install the latest.

ShamusVW
3rd February 2010, 08:23
Thanks, I have eventually managed to get it working.
I had to install Qt onto the target machine, VERY inconvenient, but it works. I eventually got past the runtime error, what I had to do was build the library on the target machine itself. I.e. on my computer I had MySQL installed, but on the target computer, I had a MySQL-Connector installed, and once I rebuild these libraries (after installing Qt!) it worked. I gues I could have installed mySQL on the target machine as per my installation, that might have worked.
Anyway, once I got past this specific runtime error, it gave another something relating to the entry point in QCore4.dll or something, but with Qt installed, it worked fine!
Thanks for the help. It would actually have been nice to test all this on a clean computer, but unfortunately the target computer also has other applications on, so possibly there is some kind of conflict somewhere.
Hope this helps others.
Anyone wanting to comment/advise, please do.

nikhilqt
3rd February 2010, 08:47
.
I had to install Qt onto the target machine, VERY inconvenient, but it works.
Anyone wanting to comment/advise, please do.

Open the executable in dependency walker and include all those dlls for deployment(not system dlls, check only 3rd party).

schnitzel
3rd February 2010, 16:39
Thanks, I have eventually managed to get it working.
I had to install Qt onto the target machine, VERY inconvenient, but it works.


of course installing Qt on the target machine is a solution but you didn't really solve the problem.


I eventually got past the runtime error, what I had to do was build the library on the target machine itself. I.e. on my computer I had MySQL installed, but on the target computer, I had a MySQL-Connector installed, and once I rebuild these libraries (after installing Qt!) it worked. I gues I could have installed mySQL on the target machine as per my installation, that might have worked.

no kidding... you could have saved yourself some frustration if you would have mentioned that sooner. I thought it goes without saying that the way you connect to the database would be the same on the dev machine as on the target, especially if you are in control of the target machine.

If I were you, I'd still try to get it to work properly, i.e. without installing Qt on the target machine.... but hey, not much of an incentive if it is working now.

This should have worked on the target provided that MySQL client library is installed (libmysql.dll is in the path):

http://www.qtcentre.org/threads/24775-Deploying-on-Windows?p=120208#post120208

(I know you have read this before, but I believe you didn't follow the suggested configuration exactly)

You also should learn how to use the dependency walker (depends.exe - free download) as suggested a couple of times.

ShamusVW
4th February 2010, 05:21
Thanks for the input. I agree that it would be nice to get this ironed out properly.
I did use dependency walker at one point, but before I figured out that it was the library that needed to be rebuilt, haven't done it again.
The files I needed are (as in your link provided)
QtCore4.dll
QtGui4.dll
QtSql4.dll
mingwm10.dll
sqldrivers\qsqlmysql4.dll

and then also libgcc_s_dw2-1.dll (which is a new requirement). I initially didn't know about the qsqlmysql4.dll being needed in the sqldrivers directory.
Also, when the MySQL bit was previously disabled, I didn't get the entry point error in QCore4.dll, but then installing Qt got it working.
My question is how will I get the library built on the target machine if Qt isn't installed previously on it as well? This is the commands I assume are what gets the final libraries created?


qmake "INCLUDEPATH+=C:\MySQL\include" "LIBS+=C:\mysql\lib\opt\libmysql.lib" mysql.pro
mingw32-make

It seems to need the Qt installed?
When I get a chance, I will play some more. Really appreciate your help, and I will also try the dependency walker again.

schnitzel
4th February 2010, 17:20
I think you are confusing the mysql client dll (libmysql.dll - comes with mysql) with the qt sql plugin.
The mysql client dll is the one that needs to be present on the target machine and needs to be installed separately.

There is an optional step when you run the mysql installer to install files needed for s/w development - these are the mysql.h and libmysql.lib. These two are needed by Qt for building its qsqlmysql4.dll, but once built and deployed, there is no need to build it again on the target.

A cool way to test installers is to run them in a Virtual Machine (look at VMWare's Player (http://www.vmware.com/products/player/)).

ShamusVW
5th February 2010, 05:24
on my computer I had MySQL installed, but on the target computer, I had a MySQL-Connector installed

This is the reason I believe it didn't work initially, until I had rebuilt qsqlmysql4.dll on the target machine to use its version of the MySQL library.
The only way to do this on my computer, would be to install the connector on my computer (to duplicate the deployment computer), build the library, and then transfer this qsqlmysql4.dll to the target computer.


The mysql client dll is the one that needs to be present on the target machine and needs to be installed separately.

If I had a clean (i.e. no Qt, Creator or MySQL installed) deployment computer, and I built all the different libraries on my development computer, would I still need to install MySQL (e.g. the connector) on the deployment computer, or would it be enough just to deploy with the relevant libraries, which would include libmysql.dll and qsqlmysql4.dll, this last one in a subfolder called sqldrivers, and libmysql.dll being the one from my computer?

JohannesMunk
5th February 2010, 11:24
You can try deployment in a clean virtual machine -> www.virtualbox.org

When building with mingw I need to deploy the following files to the app target directory to get mysql working:

"libgcc_s_dw2-1.dll"
"libmysql.dll"
"mingwm10.dll"
"QtCore4.dll"
"QtGui4.dll"
"QtSql4.dll"
"sqldrivers\qsqlmysql4.dll"

and some others not relevant here..

HIH

Johannes

ShamusVW
5th February 2010, 11:36
I will look into this virtual-box.
VMWare's Player costs a bit of money, although I did see there is a demo, but not sure what that entails.
These are the exact files I had too on the target computer, but didn't work until I had rebuilt libraries ON target computer with version of MySQL ON target computer, although I can swear the version of libmysql.dll I used is what I put into the directory directly from my computer, and so I would think it should work, but maybe it located the installed version (diferent to my version), and used that instead, hence the error.
Ultimately, I need to uninstall everything, and try again.
Next week's job!
Once again, thanks for all the input.

schnitzel
5th February 2010, 17:03
What JohannesMunk suggests sounds right.

Is it possible that the versions of mysql were too different between target and dev machine?

VMWare Player is a free download. I am not familiar with virtualbox, but I would think it is a similar product.


If I had a clean (i.e. no Qt, Creator or MySQL installed) deployment computer, and I built all the different libraries on my development computer, would I still need to install MySQL (e.g. the connector) on the deployment computer, or would it be enough just to deploy with the relevant libraries, which would include libmysql.dll and qsqlmysql4.dll, this last one in a subfolder called sqldrivers, and libmysql.dll being the one from my computer?

Yes you have to install something from MySQL onto the target, either by deploying libmysql.dll yourself or (safer) run the MySQL installer and select only the development libraries/ headers. You shouldn't need to rebuild qsqlmysql4.dll on the target because that would defeat the whole purpose of deployment.

No need to install any of the connectors. The combination of libmysql.dll, QtSql4.dll and qsqlmysql4.dll plugin is your 'connector' to the mysql database.

Again, do all this in a vm until it works.

good luck