【发布时间】:2013-11-03 08:14:11
【问题描述】:
我正在尝试使用 QtCreator 中的 te WinAPI 编译一个简单的类似 helloworld 的非 Qt C++ 应用程序。代码如下:
#include <windows.h>
int main()
{
HWND cons = GetConsoleWindow();
SetWindowText(cons, L"I am the console window");
MessageBox(cons, L"Hello world!", L"I am the MessageBox", MB_OK | MB_ICONERROR);
return 0;
}
看起来很简单,但是当我尝试构建它时,编译失败:
main.obj:-1: error: LNK2019: unresolved external symbol __imp__MessageBoxW@16 referenced in function _main
main.obj:-1: error: LNK2019: unresolved external symbol __imp__SetWindowTextW@8 referenced in function _main
我开始寻找,我找到了this,但它对我一点帮助都没有,因为当我写下这个时:
LIBS += -L"C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\Lib"
甚至这个:
LIBS += -L"C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\Lib\\shell32.lib"
在我的.pro 中,这些“符号”仍未解决。我在 每次更改 到 .pro-file 内容之后运行 qmake。那么,有什么想法吗?
【问题讨论】:
-
您肯定会错过与 Windows 库的链接。也许
user32.lib?
标签: c++ windows qt winapi qt-creator