Cannot run Qt example in Qt creator: The program has unexpectedly finished

僤鯓⒐⒋嵵緔 提交于 2021-01-27 19:14:28

问题


Recently I tried to upgrade Qt to 5.8.0 on Windows 7 32bit from Qt5.6.2 MSVC 2013, and I saw strange issues.

I downloaded and installed Visual Studio 2015 from this link: https://www.visualstudio.com/downloads/

After I installed Qt 5.8.0 MSVC 2015 version, Qt Creator 4.2.1 can be launched. From the welcome page, I selected the example named: "Address Book Example". And then after clicking "Configure" project, the project is listed in Qt Creator.

Now I tried to build the project, which was successful. But when I tried to run the project, I got the following error messages:

Starting C:\Qt\Examples\Qt-5.8\widgets\itemviews\build-addressbook-Desktop_Qt_5_8_0_MSVC2015_32bit-Debug\debug\addressbook.exe...
The program has unexpectedly finished.
C:\Qt\Examples\Qt-5.8\widgets\itemviews\build-addressbook-Desktop_Qt_5_8_0_MSVC2015_32bit-Debug\debug\addressbook.exe crashed.

I didn't see this kind of error before when I was using Qt5.6.2 with MSVC 2013. I also tried the following things:

  • Reinstall Qt5.8.0 MSVC 2015 using offline installer
  • Reinstall Qt5.7.1 MSVC 2015 using offline installer
  • Reinstall Qt5.6.2 MSVC 2015 using offline installer
  • Reinstall Qt5.8.0 using online installer, in which I chose MSVC 2013 and MSVC 2015

I still kept getting the same error messages.

When I went to the debug folder, double clicked the exe file, it said some Qt dlls were missing. I then manually copied to the debug folder, then the exe can be run with no problem.

Now I want to run app from inside Qt Creator, but not sure what is the issue with Qt Creator 4.2.1. I researched in Google for a few hours, but still cannot find out the reason why Qt Creator cannot run projects even it's own Example projects. (same errors for my own projects)

I feel it must be something to do with Qt creator environment/settings. Anyone has any ideas about this problem?

Update 1:

I tried to use MinGW with Qt Creator, the addressbook example can be run correctly. Looks like it's related to MSVC 2015. I need MSVC 2015, because all other environments don't support webenginewidgets, and I got:

:-1: error: Unknown module(s) in QT: webenginewidgets

Not sure if this is a bug in Qt or Qt creator.

Update 2:

In my Qt Creator, I saw warning icons for MSVC 2013 and MSVC 2015 compilers, please see the screenshots below:


回答1:


I finally resolved the issue. The reason is that the Windows 10 SDK is missing.

After I download and install all default components of the Windows 10 SDK, everything worked on Windows 7 32bit.

Basically, to make sure we can use Qt5.8.0+ on Windows (including Qt WebEngine), we need to install both:

  • Visual Studio 2015, and
  • Windows 10 SDK



回答2:


I'm late but I've found the main culprit is "ucrtbased.dll".

I didn’t install Windows 10 SDK.

I'm on Windows 7 SP1 x64, Qt 5.9.2 with Visual Studio Build Tools 2015 (v14.0.25420.1) and Windows 8.1 SDK with MS Debugger Tools (CDB) installed. The Release Configuration builds are without any issue but the Debug Configuration exhibits the same crash behavior. The fix is simple. The normal install of Visual Studio Build Tools 2015 with Win8.1 SDK places "ucrtbased.dll" in "C:\Program Files (x86)\Windows Kits\10\bin\x64\ucrt" for 64-bit and "..\x86\ucrt" for 32-bit builds - even the Windows 10 SDK is not installed. If these are included in system path, or copied to the Qt's current project build folder, the issue is simply resolved.



来源:https://stackoverflow.com/questions/42106240/cannot-run-qt-example-in-qt-creator-the-program-has-unexpectedly-finished

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!