Qt windeployqt 失败并提示:似乎不是 Qt 可执行文件?

5

我有一个使用mingw8.1 gcc作为编译器在Windows上运行的qt c++纯程序。

我可以在qt creator中运行它。

但是当我想使用windeplotqt进行部署时,出现了错误:

a.exe does not seem to be a Qt executable

我的步骤是:

1. copy the exe from build-xxx-release/release/a.exe to a clean folder
2. open terminal from QT(mingw) from my windows start menu
3. cd the clean folder in terminal
4. windeployqt a.exe

那么错误就出现了。

这让我发疯,因为我已经多次重新安装了QT。我可以确定我的qt是一个干净的环境。

有人能帮忙吗?


你能展示一下你的命令吗? - bogdyname
windeployqt a.exe(a.exe是我的可执行文件) - nick
你为什么要复制exe文件呢?你是否调用了正确的windeployqt.exe(正确的架构)? - chehrlic
@chehrlic 我读了一篇博客,它告诉我将exe文件复制到单个文件夹中,然后运行windeployqt。我认为我使用的是正确的版本,因为我只有一个QT版本(QT 6.0.3 with mingw 8.1)。 - nick
为了运行windeployqt,应用程序需要是Qt应用程序。这意味着它需要导入一个qt头文件。尝试在main.cpp中包含#include<QString>并在主函数中创建一个临时变量QString tmp("")。我认为这将满足要求。 - slayer
1
不要重新安装Qt。这从来不是问题。 - Kuba hasn't forgotten Monica
1个回答

2
也许你使用了错误的"windeployqt"。
在Windows 10中,尝试找到Qt安装目录,例如C:\Qt\Qt6.1.0\6.1.0\msvc2019_64\binC:\Qt\Qt6.1.0\6.1.0\mingw81_64\bin
你的"windeployqt.exe"可能在"msvc2019_64"、"mingw81_64"或其他目录中。 然后使用命令,例如C:\Qt\Qt6.1.0\6.1.0\msvc2019_64\bin\windeployqt.exe a.exeC:\Qt\Qt6.1.0\6.1.0\mingw81_64\bin\windeployqt.exe a.exe ,而不是windeployqt.exe a.exe

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接