【发布时间】:2021-06-08 13:31:54
【问题描述】:
我正在尝试让 Qt 为 Windows 工作。我开始于:https://wiki.qt.io/Building_Qt_5_from_Git#Getting_the_source_code。
我可以克隆 Git 存储库,但没有任何效果:
..\\qt5\configure -developer-build -opensource -nomake examples -nomake tests
它给我带来了找不到命令的错误:
+ CategoryInfo : ObjectNotFound: (../qt5/configure:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
文件 configure 和 configure.bat 存在于正确的位置... 运行 nmake 会导致缺少 makefile 的错误...
我没有看到有二进制文件,我安装了它。
现在,在 QtCreator 中,我遇到了另一个问题。我尝试添加一个新的空项目,当我必须输入一个工具包时,我得到了这个:
捕获:
我必须做什么?我无法选择任何人。
重新安装Qt后,我可以找到工具包,但是当我编译一个简单的程序时:
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
return app.exec();
}
我收到了这个错误:
MSVCRTD.lib(exe_winmain.obj):-1: error: LNK2019: unresolved external symbol WinMain r‚f‚renc‚ in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)
最后将 CONFIG += 控制台添加到 .pro 文件解决了这个问题。
【问题讨论】:
-
你用的是什么编译器,你也在用cmake吗?请更准确。
-
看起来您没有按照 Windows 说明操作,请使用反斜杠而不是正斜杠
-
不,我使用了正确的语法,这是我复制/粘贴代码的错误,对不起。
-
我使用:..\\qt5\configure -developer-build -opensource -nomake examples -nomake 测试。我不知道如何更精确,我不使用 cmake,我只是按照 qt 链接上的说明进行操作。没有任何工作。
-
您的子系统是什么,是 Subsytem:Windows 还是 Subsystem:Console?使用
main()意味着使用 Subsystem:Console 或mainCRTStartup。