我正在构建一个 C++ 应用程序,需要在 Windows 上使用 PDCurses。我正在使用来自 MS VS 2005 的 VC++ 进行编译,但出现链接错误。
error LNK2019: unresolved external symbol __imp__GetKeyState@4 referenced in function __get_key_count
共有 11 个错误,错误代码相同,符号不同。缺少的符号是 __imp__MapVirtualKeyA@8、__imp__FindWindowA@8、__imp__wsprintfA、__imp__SendMessageA@16、__imp__GetWindowThreadProcessId@8、__imp__MessageBeep@4。这几乎就像 VC++ 找不到这些函数的适当 ASCII 实现一样。我还应该注意到,PDCurses 附带的演示程序编译得很好,尽管它们是 C 程序。
在 C++ 程序中,我使用
包含 headerextern "C"
{
#include <curses.h>
}
我确定我忘记链接某些 C 标准库,但我不确定是哪个。
最佳答案
GetKeyState() 是“user32.dll”中的 Windows 函数,因此您需要确保链接到“user32.lib”。您可能还需要确保它也出现在链接器库列表中的 PDCurses 库之后。
关于c++ - 如何将 PDCurses 链接到 Windows 上的 C++ 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/399538/