简体   繁体   English

Qt 应用程序不在 Qt Creator 中执行

[英]Qt application does not execute inside Qt Creator

I am developing a cross platform Qt audio application.我正在开发一个跨平台的 Qt 音频应用程序。 On Linux, the application runs without any problems, but on Windows the application do not execute when started from the Qt Creator.在 Linux 上,应用程序运行没有任何问题,但在 Windows 上,当从 Qt Creator 启动时,应用程序无法执行。

When running with the Release configuration (or without debugging), Qt Creator simply says:当使用 Release 配置(或不调试)运行时,Qt Creator 只是说:

"The program has unexpectedly finished." “程序意外地结束了。”

If I run with the Debug configuration (or debugging), Qt Creator says:如果我使用 Debug 配置(或调试)运行,Qt Creator 会说:

"During startup program exited with code 0x0000135." “在启动期间程序退出,代码为 0x0000135。”

Since googling for the error did not helped at all, I decided to copy every .exe and .dll (needed Qt libraries - like QtCore - included) needed by my application to an empty directory and the application executed perfectly, just like under Linux.由于谷歌搜索错误根本没有帮助,我决定将我的应用程序所需的每个 .exe 和 .dll(需要 Qt 库 - 如 QtCore - 包括在内)复制到一个空目录,并且应用程序完美地执行,就像在 Linux 下一样。

So, I'm guessing this is a problem with the Windows not finding the dll's needed by my application.所以,我猜这是 Windows 没有找到我的应用程序所需的 dll 的问题。

This problem appeared last weekend when I upgraded my system to Windows 8. Previously (with Windows 7) I had no such problem.上周末我将系统升级到 Windows 8 时出现了这个问题。以前(使用 Windows 7)我没有这样的问题。

Does anyone know a solution that do not involves modifying the build parameters (which are stored at the file .user)?有谁知道不涉及修改构建参数(存储在文件 .user 中)的解决方案?

I don't want to do this because this file will be invalidated when I test the application under Linux, and I don't want to keep to versions of it.我不想这样做,因为当我在 Linux 下测试应用程序时,这个文件将失效,我不想保留它的版本。

Just solved it!刚刚解决了!

Probably a bug in Qt Creator.可能是 Qt Creator 中的一个错误。

My project has 4 sub-projects inside: main.exe, a core.dll, side.dll, external.dll.我的项目里面有 4 个子项目:main.exe、core.dll、side.dll、external.dll。

main.exe needs core.dll and side.dll
core.dll needs external.dll

Since main.exe needs only core.dll and side.dll, I have not added a reference to external.dll.由于main.exe只需要core.dll和side.dll,所以我没有添加external.dll的引用。 Qt Creator should be smart enough to detect its dependencies and add them accordingly (well, at last this is what happens under Linux). Qt Creator 应该足够聪明以检测其依赖项并相应地添加它们(好吧,这就是 Linux 下发生的事情)。

Since it don't detect correctly the dependencies, it does not build the correctly PATH environment variable when I try to run main.exe from Qt Creator, causing the problems.由于它没有正确检测依赖项,因此当我尝试从 Qt Creator 运行 main.exe 时,它​​没有构建正确的 PATH 环境变量,从而导致了问题。

Solved it by adding the following lines at my main.pro file:通过在我的 main.pro 文件中添加以下几行来解决它:

win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../external/release/ -lexternal
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../external/debug/ -lexternal

#INCLUDEPATH += $$PWD/../external
win32: DEPENDPATH += $$PWD/../external

Note: I changed the modules names for better understanding.注意:为了更好地理解,我更改了模块名称。

I guess it is because the path in executing environment doesn't contain path for Qt-DLLs any more.我猜这是因为执行环境中的路径不再包含 Qt-DLL 的路径。 Go to Project Settings and check the PATH variable in "Debugging and Execution" Settings In my case eg: C:\\QtSDK\\mingw\\bin;C:\\QtSDK\\Desktop\\Qt\\4.8.1\\mingw\\lib;...Other paths...转到“项目设置”并检查“调试和执行”设置中的 PATH 变量在我的情况下,例如:C:\\QtSDK\\mingw\\bin;C:\\QtSDK\\Desktop\\Qt\\4.8.1\\mingw\\lib;...其他路径...

regards.问候。

The problem is definitely with some missing dll(s)!问题肯定是缺少一些dll! I've found out that when I put dll's directly into folder(for instance png3.dll) with executable and then running it from qt creator it will run!!我发现当我将 dll 直接放入带有可执行文件的文件夹(例如 png3.dll)中,然后从 qt creator 运行它时,它会运行!! What I did: in your output directory(where executable lies) you open your executable(double click), Windows shows dll names that are missing.我所做的:在您的输出目录(可执行文件所在的位置)中,您打开您的可执行文件(双击),Windows 显示缺少的 dll 名称。 You find them and copy directly into the folder.您找到它们并直接复制到文件夹中。 Then run app from Qt creator!然后从 Qt Creator 运行应用程序! You should succeed if dlls are suitable.如果 dll 合适,您应该会成功。 After that you try removing dlls from the exec folder and run app through qt creator till the moment it throws error again.之后,您尝试从 exec 文件夹中删除 dll 并通过 qt creator 运行应用程序,直到它再次引发错误为止。 This way you find the missing dll.这样你就可以找到丢失的dll。 After that you add the path to dll in qt creator "projects" settings in "build environment" into "Path" variable.之后,将“构建环境”中的qt创建者“项目”设置中的dll路径添加到“路径”变量中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM