Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试编译以下代码,但出现链接器错误。谢谢你告诉我我错过了什么。
#include <Windows.h> #pragma comment(lib,"user32.dll") int main() { return MessageBoxA(0,"Message","Warn",0x01); }
fatal error LNK1104: cannot open file 'user32.dll'
由于 LIB 文件用于在编译时链接到 DLL,因此 MessageBoxA 位于 user32.dll 中,并且需要 user32.lib 才能正确链接。所以在#pragma 评论中更改user32.dll为user32.lib
user32.dll
user32.lib
#pragma comment(lib,"user32.lib")