App.exe has encountered a problem and needs to close (Windows)



  • I've managed to deploy my application to another machine (XP). This was good. Then I tried to do the same thing on two other machines (also XP), but I got "app.exe has encountered a problem and needs to close". I can't see any difference between the two machines. All the files are there (I think). Any ideas what this could be?

    Thanks for any help.



  • Did you install the correct MSVC runtimes on that machine?

    How did you deploy it on the other machine?

    Did you use the correct MSVC distributable on the other xp machine? You cannot simply copy the msvc runtime dll's (from like windows 7) to another machine.

    -bms



  • Thanks for the reply. I'm not really sure about this though. I developed it on Windows 7, and as far as I remember, I just put the files on the first XP and added libmysql.dll to c:/windows. I don't remember even thinking about MSVC runtimes - maybe I'd had a few beers.

    I've just downloaded and installed the thing from here - http://www.microsoft.com/download/en/details.aspx?id=5555 , bu that didn't fix the problem. I then installed Dependency Walker, but I didn't see anything too strange. It highlighted MPR.DLL and SHLWAPI.DLL but the faq on the Dependency Walker site says not to worry about that.

    What should I do next?

    [edit]
    I've gone back to Dependency Walker and checked after reading the instructions on this site more carefully. I found it needs msvrc.dll, and that is in the right place, so that seems to be OK.

    I found problems with something different when I ran 'profile'.

    GetProcAddress(0x7C800000 [KERNEL32.DLL], "FlsAlloc") called from "SNXHK.DLL" at address 0x64D14D5D and returned NULL. Error: The specified procedure could not be found (127).
    GetProcAddress(0x7C800000 [KERNEL32.DLL], "FlsGetValue") called from "SNXHK.DLL" at address 0x64D14D6A and returned NULL. Error: The specified procedure could not be found (127).
    GetProcAddress(0x7C800000 [KERNEL32.DLL], "FlsSetValue") called from "SNXHK.DLL" at address 0x64D14D77 and returned NULL. Error: The specified procedure could not be found (127).
    GetProcAddress(0x7C800000 [KERNEL32.DLL], "FlsFree") called from "SNXHK.DLL" at address 0x64D14D84 and returned NULL. Error: The specified procedure could not be found (127).
    GetProcAddress(0x7C800000 [KERNEL32.DLL], "EncodePointer") called from "SNXHK.DLL" at address 0x64D1490C and returned 0x7C9132D9.

    GetProcAddress(0x7C900000 [NTDLL.DLL], "LdrRegisterDllNotification") called from "SNXHK.DLL" at address 0x64D0E13B and returned NULL. Error: The specified procedure could not be found (127).
    GetProcAddress(0x7C900000 [NTDLL.DLL], "LdrUnregisterDllNotification") called from "SNXHK.DLL" at address 0x64D0E148 and returned NULL. Error: The specified procedure could not be found (127).

    GetProcAddress(0x7C800000 [KERNEL32.DLL], "GetTickCount64") called from "QTCORE4.DLL" at address 0x6A2236FD and returned NULL. Error: The specified procedure could not be found (127).

    LoadLibraryW("C:\WINDOWS\system32\wintab32.dll") returned NULL. Error: The specified module could not be found (126).

    GetProcAddress(0x7E410000 [USER32.DLL], "UpdateLayeredWindowIndirect") called from "QTGUI4.DLL" at address 0x6517D5DC and returned NULL. Error: The specified procedure could not be found (127).

    GetProcAddress(0x7E410000 [USER32.DLL], "SetProcessDPIAware") called from "QTGUI4.DLL" at address 0x6517D765 and returned NULL. Error: The specified procedure could not be found (127).

    GetProcAddress(0x7E410000 [USER32.DLL], "GetGestureInfo") called from "QTGUI4.DLL" at address 0x6517D889 and returned NULL. Error: The specified procedure could not be found (127).

    GetProcAddress(0x7E410000 [USER32.DLL], "GetGestureExtraArgs") called from "QTGUI4.DLL" at address 0x6517D953 and returned NULL. Error: The specified procedure could not be found (127).

    ... and others.

    This particular machine is very dodgy - it often reboots itself for no apparent reason. Is all of this related to that, do you think?
    [/edit]

    Thanks again.



  • So the first thing I would do is get the machine working correctly.

    Although XP is terrible, it shouldn't reboot. I'd work that out first. My most recent XP test machine died with a hardware problem, but just prior to it failing to boot the machine would lock up when doing opengl graphics. You may consider something like virtual box to give you a clean XP test machine on hardware that you know works.

    Secondly, I wouldn't put mysql.dll into the windows directory. Place it alongside the .exe file you are running. The loader will pick it up from there.

    Thrid, can you verify that the mysql dll file was built with the same microsoft visual studio version as your project and/or that it has no requirement for a visual studio runtime library? My understanding is that the VC runtimes vary by version of visual studio, AND by windows kernel version; hence you cannot copy msvcrtXX.dll from win7 to XP (for example).

    If you print out "hello world" as the first line in main of your program, and compile it in console mode, do you see this coming out on the console prior to the application error?

    If that works, its time to rebuild in debug/console mode and test your application on xp. There are variations between the operating systems, but a failure on one is indicative of a failure on both.

    -bms



  • bms,

    Thanks for your reply.

    I found the problem (kind of by chance) by debugging. I have this function returning QFileInfo. [code]QFileInfo MainWindow::getNewestFile(bool compFile) {
    QDir dir;
    QFileInfo newest;
    if (compFile==0) {
    dir = vars("vidFolder");
    }
    else {
    dir = vars("compressedVidFolder");
    }
    dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
    dir.setSorting(QDir::Time);
    QStringList filters;
    filters << ".wmv" << ".mp4" << ".mpg" << ".mp3";
    dir.setNameFilters(filters);
    QFileInfoList list = dir.entryInfoList();
    newest = list.at(0);
    return newest;
    }[/code]
    When there is at least one file in the directory I'm checking, I'm OK, so on the machine I built it on and the one I deployed on, I was OK, because there were some files there. When I put it on the other machines, it crashed because there was nothing to return (or because another function was trying to do something with the results of this function). I tried to change this by having it return false or something if the directory was empty, but as the function is supposed to return QFileInfo, the complier was rejecting it. I wasn't sure what to do, so I did something hacky and had it copy an empty file into the directory when the application starts. Now it's working OK, but obviously, I'd like a better solution. Do you know an easy way to solve this problem?

    About the XP machine with problems, yeah, it's obviously not good, but I've tried all sorts of things to fix it. I think I'm about to give up on it though as it's a pain. I have an older (but at least) working machine that I can replace it with for now.

    I got the idea to put the libmysql.dll in the Windows directory from here: http://www.pikopong.com/blog/2011/07/11/how-to-enable-mysql-support-in-qt-sdk-for-windows-part-2/
    That article worked well for me, so I assumed that bit was OK too.



  • Well, there are a couple of basic things there:

    First off, I wouldn't compare a bool against an integer. The complier allows this, and your code will work, I would suggest comparing against true and false, or treating your boolean variable as a logical:

    @if (!compFile) {
    ...@

    Secondly, the main problem is where you write:

    @newest = list.at(0);@

    The assumption here is that list is of size one or larger; which crashes on empty lists.

    The solution is just to bracket the assignment:
    @if (list.size() > 0) {
    newest = list.at(0);
    }@

    That is it. You can safely return newest by copying (as you are doing) - however, in the caller you must check to see that newest is a valid file. Refer to QFileInfo's documentation to see how to do this.

    Good luck.
    -bms



  • Thanks. I do need basic things pointed out to me because I've just kind of jumped into this and hoped for the best. I've managed to put something together that's doing what I want it to do, but there are probably loads of basic errors in my code.

    Thanks again.



  • Don't worry about it.

    Everyone has to start somewhere!

    -bms


Log in to reply
 

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