如何将 PDCurses 链接到 C++ Windows 上的应用程序?

发布于 2024-07-11 03:24:34 字数 636 浏览 5 评论 0原文

我正在构建一个 C++ 应用程序,需要在 Windows 上使用 PDCurses。 我正在使用 MS VS 2005 中的 VC++ 进行编译,但出现链接错误。

 错误 LNK2019:无法解析的外部 
   引用符号 __imp__GetKeyState@4 
   在函数 __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++ 程序中,我使用以下内容包含标头:

extern "C" 
{ 
    #include <curses.h> 
}

我确定我忘记链接某些 C 标准库,但我不确定是哪一个。

I'm building a C++ application and need to use PDCurses on Windows. I'm compiling with VC++ from MS VS 2005 and I'm getting a link error.

 error LNK2019: unresolved external
 symbol __imp__GetKeyState@4 referenced
 in function __get_key_count

There are 11 errors all with the same error code and different symbols. The missing symbols are __imp__MapVirtualKeyA@8, __imp__FindWindowA@8, __imp__wsprintfA, __imp__SendMessageA@16, __imp__GetWindowThreadProcessId@8, __imp__MessageBeep@4. It is almost like the VC++ can't find the appropriate ASCII implementations of these functions. I should also note that the demo programs that come with PDCurses compiled fine, though they are C programs.

In the C++ program, I include the header using

extern "C" 
{ 
    #include <curses.h> 
}

I'm sure I'm forgetting to link against some C standard library, but I'm not sure which one.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

So要识趣 2024-07-18 03:24:34

GetKeyState() 是“user32.dll”中的 Windows 函数,因此您需要确保链接到“user32.lib”。 您可能还需要确保它也位于链接器库列表中的 PDCurses 库之后。

GetKeyState() is a Windows function in "user32.dll", so you need to be sure you're linking against "user32.lib". You may also need to make sure it comes after the PDCurses library in the list of linker libraries, too.

一张白纸 2024-07-18 03:24:34

您是否使用 MS VC++ 在您的计算机上构建了 PDCurses? 如果是这样,我不确定发生了什么。 如果不是,那么您使用的很有可能与 MS VC++ 不兼容。 混合来自不同 C++ 编译器的代码是一件令人担忧的事情。 它还有点取决于您所说的“其他几个错误”的含义。 如果这是对“数百个错误”的怪诞轻描淡写,那么这可能就是问题所在。 如果您只有几个(比如另外六个或更少)类似的错误,那么它不太可能成为问题。

Did you build PDCurses on your machine - with MS VC++? If so, I'm not sure what's up. If not, then there's a decent chance that what you are using is not compatible with MS VC++. Mixing code from different C++ compilers is fraught. It also depends a bit on what you mean by 'several other errors'. If that's a grotesque understatement for 'hundreds of errors', then that is likely the trouble. If you have just a few (say another half dozen or fewer) similar errors, then it is less likely to be the trouble.

鱼窥荷 2024-07-18 03:24:34

好吧,我想通了;)我正在使用 scons 进行构建,我将 user32.lib 包含在变量 USER32_LIB 中,该变量默认为空字符串,但在 Windows 上它被定义为 user32.lib 。 在Windows部分,我有一个拼写错误,我有USER32_LIb而不是USER32_LIB

Okay, I figured this out ;) I'm building with scons, I was including user32.lib with a variable USER32_LIB, which defaults to an empty string except on windows where it gets defined to user32.lib. In the windows section, I had a typo, I had USER32_LIb rather than USER32_LIB.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文