Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Qt:windows函数是未解析的外部符号 我试图在QtCreator使用TE WiNAPI编译一个简单的类似于HQReloLD的非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; }_C++_Windows_Qt_Winapi_Qt Creator - Fatal编程技术网

Qt:windows函数是未解析的外部符号 我试图在QtCreator使用TE WiNAPI编译一个简单的类似于HQReloLD的非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; }

Qt:windows函数是未解析的外部符号 我试图在QtCreator使用TE WiNAPI编译一个简单的类似于HQReloLD的非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; },c++,windows,qt,winapi,qt-creator,C++,Windows,Qt,Winapi,Qt Creator,我开始寻找,我发现了,但这对我毫无帮助,因为当我写下这篇文章时: 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-文件内容的每次更改后运行qmake。那么,

我开始寻找,我发现了,但这对我毫无帮助,因为当我写下这篇文章时:

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
-文件内容的每次更改后运行qmake。那么,有什么想法吗?

-L
设置DLL的搜索路径,但实际上它没有链接任何内容。实际链接通过
-l
完成。设置系统库的搜索路径应该不是必需的,但您需要针对user32进行链接:

win32:LIBS += -luser32

除了Frank的回答(这对我很有帮助,谢谢!),我想补充一点,这只是MSVC需要的,MinGW似乎不需要这句话。这对我来说是最令人困惑的部分,我第一次认为我在msvc工具链上有问题

现在,我将其包括在内,以反映这一事实:

msvc: LIBS += -luser32

您肯定错过了与Windows库的链接。也许
user32.lib
?它使行的其余部分特定于Windows(以防您想在其他地方构建项目)
msvc: LIBS += -luser32