c - <windows.h> 函数触发 Pelles C 中的 POLINK 错误

标签 c winapi pelles-c

我有一个简单的程序 ( program.c ),我正在使用 Pelles C 进行编译:

#include <windows.h>
void main() {
    char buffer[256];
    GetKeyboardState(buffer);
}

当我尝试编译这个程序时,after enabling Microsoft Extensions ,失败了:

Building program.obj.
Building program.exe.
POLINK: error: Unresolved external symbol '__imp_GetKeyboardState'.
POLINK: fatal error: 1 unresolved external(s).
*** Error code: 1 ***
Done.

我怎样才能做到这一点?

最佳答案

这里的问题出在链接器上。这表明该程序需要链接到它未链接到的库。 documentation page for this function表示所需的库是 User32.lib

要链接到库,请单击“项目”->“项目选项...”,然后选择“链接器”选项卡。 “库和目标文件:”框中可能会有库;将 User32.lib (不区分大小写)添加到此空格分隔的列表中。

您的程序现在应该可以编译了。

关于c - <windows.h> 函数触发 Pelles C 中的 POLINK 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41361784/

相关文章:

c++ - 无法使 SHGetKnownFolderPath() 函数正常工作

c - C 和 Windows Vista 中的 Dos.h + Pc.h

c - 链接到 Pelles C 中的 DLL

python - 在python中调用C程序函数-段错误

c - 这个自定义 toupper() 函数如何工作?

c - 使用 strcmp 比较字符指针和文字

c++ - 优化 Stack-Walking 性能

c - 为什么这个排序功能不起作用? C

c++ - GetPath() 是否返回三次或二次贝塞尔曲线控制点?

c - Windows API : Programmatically moving the Windows IME Input box possible?