Serious issue with starting application in QtCreator - c++

I have been writing an application for two years in QtCreator. (My application uses some external libs).
Recently I've ported the application into Qt5.3mingw(windows7). The application built successfully but failed to start within QtCreator and gave "The program has unexpectedly finished.".
With debugging the application, it gives this error message: "During startup program exited with code 0xc0000135".
However the application starts succussfully outside of QtCreator! It seems the QtCreator has severe problem in starting the application or it's the linker problem.
I've even uninstalled all Qt and QtCreators and re-installed them, but the problem insists.
Any guide will be appreciated. Thanks.

Status code 0xC0000135 is STATUS_DLL_NOT_FOUND.
There's some DLL that your program is dependent on that is not in a directory being searched when launched from the QtCreator IDE.
You may need to make sure the PATH is set correctly for QtCreator.
Also, a tool like Dependency Walker may be able to help you figure out what DLL is the problem. I'm not sure why Windows doesn't make it easier to find out what DLL can't be found.

Related

Cannot run Qt Creator GUI outside of Qt. "The application was unable to start correctly (0xc000007b)" error

I downloaded C++ code from GitHub to tag images for training an object detector using Machine Learning.
Within Qt Creator 4.2.1 Based on Qt 5.8.0 (MSVC 2015, 32bit), I was able to compile and run the code. Unfortunately, I was not able to run the .exe outside of Qt Creator.
Initially, I received an error that
"The program can't start because libgcc_s_dw2-1.dll is missing".
Thanks to
QT The program can't start because libgcc_s_dw2-1.dll is missing, that was fixed easily by adding
"QMAKE_LFLAGS += -static"
to the .pro file. Now, when I run it I get
"The application was unable to start correctly (0xc000007b). Click OK to close the application."
I was able to reproduce the error using the simple "Hello World" default project that appears when you create a Qt Widget Application. This led me to believe something was wrong with my installation.
Based on the advice of this article: https://stackoverflow.com/questions/12099117/32-bit-qt-application-on-win-7-x64-wont-run-but-runs-fine-from-qt-creator, I used Dependency Walker to identify possible causes. I expected to see only a few items that I can follow up on. Instead, I received a list of close to 100 missing .dll files. All the files started with
"API-MS-WIN ###.DLL" or "EXT-MS ###.DLL"
where ### represent some additional text characters, for example;
"API-MS-WIN-SHCORE-STREAM-WINRT-L1-1-0.DLL"
I'm attaching a sample output.
Another suggestion was to copy over
libwinpthread-1.dll, libstdc++-6.dll, libgcc_s_dw2-1.dll.
That did not work either.
My next move was to simply get the latest version of QT and wish for the best. I installed Qt Creator 4.8.1 Based on At 5.12.0 (MSVC 2015, 32 bit). This time, I could not even get the code to run in the IDE. I received 1000+ error messages!
Based on advice from several pages, I added
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
to the .pro file and it still would not compile.
Also, I verified that the application is being built as a 32bit application. I'm running on a 64 bit Windows 10 system.
If anyone would like to take a crack at it to see if they can create a working .exe, here is the link: github.com/clavicule/BBTag
Qt provides a tool to copy the necessary dlls to the folder of your executable.
The tools is called windeployqt.exe and comes with your Qt installation. For me it is located at C:\Qt\5.9.1\msvc2015_64\bin\windeployqt.exe. You will have to look at your installation path and probably the msvc_32 folder to find it.
Then you go to the folder with your executable in it, oben a command prompt or powershell and execute path\to\windeployqt.exe yourProgram.exe and it will automatically copy the necessary dll files to this folder. Afterwards you can run your program without issues.
The official documentation for the tool can be found here.
Alternative 1: While developing you could use QtCreator which automatically adds the paths to the dlls when running your program - make sure to include them if you deploy your program!
Alternative 2: Add the path to the necessary dlls to your PATH variable. This isn't recommended either, since everyone who gets your program would have to do the same to run it.
I figured it out! My installation of Anaconda (a Python distribution popular for data science and machine learning) is the culprit.
From: #remy-lebeau
The application was unable to start correctly (0xc000007b)
The error:
"The application was unable to start correctly (0xc000007b) ..."
is a good indicator that the 32-bit app tried to load a 64-bit DLL. At first, this did not make sense since I verified many times that I was using the 32 bit version of Qt.
It turns out that the installation of the 64 bit version of Anaconda also contained many Qt5 dlls used for the PyQt5 package. Since the path to this folder came before the path to my c:\Qt...\bin folder, it was used in the build instead of the actual 32 bit version installed with Qt. This was not obvious because I was unaware of PyQt5 so I had no idea that it came with Anaconda. A simple reordering of the path entries using the System Environment Variables interface AND a system restart fixed the problem.
Silver lining: I now know C++ and designing GUIs w/ QT and PyQt5
Thanks #albertmand and #jwernerny

finding dll for "The specified module could not be found" [duplicate]

This question already has answers here:
Unable to load DLL (Module could not be found HRESULT: 0x8007007E)
(20 answers)
Closed 1 year ago.
I have a 32 bit .Net application winform that invokes a C++ dll. We package the app into an installer and it installs and runs fine on at least 20 or so machines. The app was originally developed and runs fine on a Win 7 x64 machine (mine).
However when I run it on my bosses desktop (Win 7 x64) the application will not launch.
oh yeah...
When I try to launch the application I get a JIT dialog with
System.IO.FileNotFoundException: The specified module could not be found. (Exception from HRESULT: 0x8007007E)
When I run depends on the exe on the bosses machine it says that app exe is x86 but that all the dependent dll at x64 and flags it as an error. When I run depends on the app on my machine the exe and dll are all marked x86.
How could this change between machines? The installer is just unpacking and copying in the normal way and works fine on plenty of other x64 machines...
naturally it only breaks on his machine which is two hours away and we have a trade show coming up. sigh.
very confused...
================= solved ==================
So we fixed it. Finding the missing the dll was a bit tricky.
First of all we goofed and we ran the wrong version of depends for an x64 box. So it was incorrectly reporting that the app was looking for x64 dll. If we had run the correct version I think we would have caught the issue sooner.
What solved it for us was looking at the log of Process Monitor from System Internals. It logs every file access and registry read. The log quickly showed a failed read on a Direct X 11 dll.
It turns out that a previous installer from some other app had installed some of the DX11 dll. That fooled our installer, and it skipped the DirectX 11 step so we had a missing dll.
Thanks for the help guys!
It is a simple "file not found" kind of error, but with the very awkward behavior that it doesn't tell you what DLL could not be found. Which might be the C++ DLL but also any implicit DLL dependencies it might have. Like the runtime support DLLs, very commonly missed, you can deploy them with the vcredist installer. Or deploying the Debug build of the DLL, that can't work.
Getting a decent diagnostic requires turning on loader snaps and a debugger. Invariably hard to do on a machine that doesn't have tools installed. The SysInternals' ProcMon utility is an excellent alternative, you'll see the program searching for the DLL. Albeit that you'll drown in the amount of trace data it generates. Work from the bottom of the trace backwards.

Basic Qt app crashes upon launch

When I launch a basic Qt app within Eclipse, it crashes with a ".exe has stopped working" error.
The context :
its the basic app obtained when creating a Qt GUI project (with a MainWindow), nothing was changed in it, haven't even added a button
PATH has all the necessary stuff (mingw, msys, qt)
project properties and eclipse paths should be ok too (c++, qt, mingw)
the .pro file is ok, no file missing
clean & rebuild, as well as relaunching eclipse doesn't resolve the problem
upon compilation there is no error, just an ignored "cannot lstat `ui_.h': No such file or directory". No relevant result found when searching around that.
if launched, stops with the afforementionned error. Details show its the app that crashed, with error code c0000005, offset 00002cb20. Search results tells me c0000005 is access violation, but where would that come from ? It's the basic app...
tried to launch with eclipse being in admin mode to prevent accesss violation, didn't help
if launched in debug mode, stops with error "Can't find a source file at ../mingw/main.c". I thought I forgot something when I installed mingw, so I did its setup again, but that did not create that file. No relevant search results here either.
my setup: eclipse classic x32 with c++ & php stuff, qt 4.8, win7 x64
I'm getting lost here. I already worked with Qt under Eclipse before (on winXP and vista), got my bunch of installing problems but this one is a first. Anybody went through this already ? Any leads on how to find where the access violation is happening ? Reading this question makes me think it's a Qt Eclipse Integration problem, but how can I circumvent that ?
Thanks for any leads !
Your project doesn't have a TARGET = set in the .pro file. This was probably caused by an Eclipse/Qt plugin wizard screw up, so just typing a new target may not work, other files may have to be renamed manually.
FWIW development on the Qt plugin for Eclipse was halted some time ago, building outside of Qt Creator is definitely one way of making life more difficult for yourself.

I run a Qt C++ project in Visual studio and got "the program can not start because QtCored4.dll" is missing

I am running a Qt C++ Project in Visual Studio 2008 and I got this error message:
"The program can't start because QtCored.dll is missing from your computer. Try installing the program to fix this problem".
Then I copy: QtCored4.dll from C:\Qt\4.8.0\bin to the exe program
I run it again, I got:
"The program can't start because QtGuid4.dll is missing from your computer. Try installing the program to fix this problem".
Then I copy: QtGuid4.dll from C:\Qt\4.8.0\bin to the exe program
Then I run it again, I got:
"the application was unable to start correctly (0xc015002). Click OK to close the program.
Then I check the Event Viewer, I see this:
Activation context generation failed for "D:\rest\rrpT.exe". Dependent
Assembly
Microsoft.VC80.DebugCRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.762"
could not be found. Please use sxstrace.exe for detailed diagnosis.
First of all, it is very strange to me because I am building and debugging the application on VS2008 but it asks for the dll files form VS2005. Then I copied those files from VS2005:
msvcm80d.dll - msvcp80d.dll - msvcr80d.dll
to the program folder but it is still the same error :(
And I think there is also something interesting:
Activation context generation failed for "C:\Bin\QtSolutions_PropertyBrowser-2.5d.dll". Dependent Assembly Microsoft.VC80.DebugCRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.762" could not be found. Please use sxstrace.exe for detailed diagnosis.
why is that PropertyBrowser is dependent on VS2005?
Any idea?
It sounds like your copy of Qt was compiled with VS2005, thus it probably has a dependency on the version 8 runtime DLLs. But your application is built with VS2008 and thus has a dependency on the version 9 runtime DLLs. In general, you can't get both versions of the runtime DLLs into one process. VC++ tends to break binary compatibility between major versions.
You need to recompile your own copies of the Qt DLLs with VS2008 or develop your application with VS2005.

Error while trying to run a release build of a Qt application on Windows

I'm trying to build the Windows version of my app. The program compiles and runs fine on Qt Creator but when I try to run it standalone it throws the following error:
The procedure entry point _Z17qt_message_output9QtMsgTypePKc could not be located in the dynamic link library QtCore4.dll
I have all the necessary dlls in my application folder and they are the same ones that came with the binaries I've downloaded from the Qt's website. This error is driving me crazy for I can't seem to find any reason for it. The application runs fine on Linux and MAC OS X.
Ok I found the problem. I was copying the wrosng dll (not sure why Qt ships with 2 different versions).
The right ones are in:C:\Qt\2010.05\qt\bin and NOT in C:\Qt\2010.05\bin
I hope this helps anyone who might stumble upon this issue.