Run time error on executing the exe manually - c++

I have a Qt application, which runs fine when I execute it from Qt Creator. However, on running it by manually clicking the generated exe, I get the following error :
I would understand if it would ask for missing DDLs (which I could then place in the same folder). But how should I proceed to handle this (in general) ?
P.S. It is not giving any line number in my source code which I could try testing this assert for. I tried using the release mode as well, but the same error.

We don't know what the problem with your code is; you'll need to use a debugger to find that out. I think that the pre-built Qt libraries that you download come with debug symbols, but if they don't, you can always build Qt yourself to get them using the -force-debug-info configure option.
You can also use DebugView to see debug output of deployed applications.
However, in general, you should use the windeployqt tool that is included with Qt.
The Qt for Windows - Deployment page has more information about deploying Qt applications to Windows machines, but windeployqt should do everything you need.

My qml files were not getting deployed properly and thus this error (this assert is probably on the variable storing the main qml file name, i.e. it should not be an empty string, which in case of missing main.qml, it was). Placing the qml files at correct paths solved the issue.
Also, as #mitch has pointed out in his answer, use windeployqt to find out the dependencies. Although, I have also realized that it doesn't cover all the dependencies (MSVC runtimes for example and other compiler related files sometimes). In that case run the dependency walker and place the missing files manually along with the exe.

Related

Qt widget application runtime error : [The Application has requested the runtime to end in an unusual way]

I am learning how to code in Qt and made a semi-Notepad like application.
It is working like a charm in my PC, but when I sent the executable file (I sent the whole debug folder with all the necessary .dll files in it) to my friend, their OS shows the following error:
[This application has requested the Runtime to terminate it in an unusual way.]
I compiled it using MinGW compiler and really can't see where the fault is.
First of all, you will prefer to do a Release compilation to provide a smaller executable and smaller set of DLLs.
As specified here http://doc.qt.io/qt-5/windows-deployment.html you will need several DLLs located in your Qt/MinGW/bin/ folder.
Most notably :
platforms\qwindows.dll
Qt5Core.dll
Qt5Gui.dll
Qt5Widgets.dll
You may also need the following, but you can try without :
icudtXX.dll
icuinXX.dll
icuucXX.dll
Trying to "Rebuild All" helped me to solve the issue. Although I had a runtime issue on the system where my application was built.

Can't find right Qt5Core.dll file. Each one I find gives a different error

I'm trying to deploy my Qt application, and every I tried loading Qt5core.dll, and it gave me an error, saying something like "procedure entry point.... could not be found".
So I tried loading a different version that was on my machine, and all of them gave me a slightly different but similar error.
Any ideas anyone?
By the look of your question, I suspect you want to deploy your project on Windows as you have struggle to find the correct .dll files.
I usually use the Windows deployement tool from Qt (more info on their website here: windeployqt, it is located within the QTDIR/bin/ folder.
But it is very straightforward to use, I use it as follow:
windeployqt --release "C:\path\to\binary.exe"
You should then be able to deploy your app by copying the resulting output files from the previous command.
Got it! I was including Qt5Network.dll when I was trying something out, but forgot I no longer needed it. It was calling a procedure in Qt5Core.dll that wasn't in the version I was using.

How to run a Qt executable file dependent on .dll files?

So I've finished my Qt application, and I need to implement testing using the Squish testing application (first time using). Apparently I require a working exe file, but I can't get the executable to run. I added all the .dll files to the same directory, only to get the error:
Prior to that I was getting errors saying that XXXX.dll is missing, but like I said, I've added them to the directory. I've tried using both debug and release builds of my project with the same results. I've also tried building a stand-alone executable, but that has it's own problems (one thing at a time). The program runs great in Qt Creator and VS2013...just not on its own.
Any solutions to this?
EDIT:
From Dependency Walker...
0x7B is the error code for invalid image format.
You're either trying to run a 64-bit application on a 32-bit system, or linking to a 64-bit library (ie you copied the wrong DLLs).
Or your binaries are just corrupted.
If you run the application standalone (i.e. not from Qt Creator) you also need the Qt library DLLs. which one you need, depends on the components you are using.
Dependency Walker is also a useful tool to find missing DLLs under Windows.
As for me it seems that something is missing. Qt on windows has the script windeployqt, it will provide all needed dependencies. See documentation http://doc.qt.io/qt-5/windows-deployment.html about use of this. On Windows you will be able to run cmd with loaded qt environment variables ( on Windows 7 see under windows applications menu - it will be available if qt is installed ). As Simon stated Dependency Walker is good tool.

Qt Release build giving MSVC++ Runtime Library Error

I have a perfectly working application (exe with around 16 DLLs) when building in Debug mode. However, as soon as I switch to Release, get the exe and all DLLs built, all required DLLs copied over from the QtSDK bin, I'm getting a runtime error.
How exactly am I supposed to troubleshoot what's happening? Is this a common issue? I don't get any entry points, etc., to even start from.. just a generic runtime error.
The only similar question I've found is here, but this is from a much older version of Qt. 4.7.4 only has one bin folder.
Edit 1 - I've commented everything out of my main.cpp except creating my MainWindow object, and everything out of my MainWindow constructor, so it should just be opening an empty window - still the Runtime Library issue.
Note - Keeping it in release mode and starting the debugger launches the application fine.
Debug -> Start and Debug External Application also results in this Runtime Library error.
Add also libEGL.dll.
See this bug for details: https://bugreports.qt-project.org/browse/QTBUG-28766
My apologies everyone. It appears the QtSingleApplication libraries aren't working correctly. I had implemented this to force any files I open to open into the one instance. I've recompiled it and it still isn't working, but just using a QApplication seems to have resolved the Runtime Library. I'll have to look into the QtSingleApplication a bit more and see why it's being a pain.
Thanks for the quick comments regardless :)

App looking for an invalid dynamic library

alt text http://img63.imageshack.us/img63/5726/screenshot20100125at124.png
I keep getting multiple error windows for an app i'm developing asking for ._libpal_bullet.dll when it should really be just libpal_bullet.dll. The weird thing is after I get all the error messages, the app runs anyway using the correct dlls that exist in the same directory.
How can i get rid of these errors?
You can use Dependencies Walker to step through the code to see who is invoking the call to the DLL. Maybe you have the ._libpal_bullet.dll included in your release configuration.
Thanks Extrakun, you indirectly helped me figure this one out.
I guess this happens when you copy code between OSes.
The problem was that there were duplicate files of these library names in the build folder. They were metadata files from OS X, which must have come over to the Windows side when I copied the folder to Windows. It's strange that they would be attempted to be executed even though they have different names to the proper DLLs.
Anyway deleting the files (they were hidden!) solved the issue.