尝试使用 pdcurses 扩展库时出现与 gdi32 相关的错误
Posted
技术标签:
【中文标题】尝试使用 pdcurses 扩展库时出现与 gdi32 相关的错误【英文标题】:Errors relating to gdi32 when trying to use pdcurses-extended library 【发布时间】:2019-12-17 08:21:27 【问题描述】:规格:
操作系统:Windows 7
IDE:代码块
编译器:GNU GCC 编译器
图书馆:PDCurses-extended
库构建平台:WinGUI(Windows 图形模式)使用位于 PDCurses-master\wingui 中的 Makefile.mng
问题:
安装并链接 PDCurses 扩展库后,我尝试编译并运行一个简单的 Hello World 程序,以检查一切是否设置正确:
#include <curses.h>
int main()
initscr(); /* Start curses mode */
printw("Hello World !!!"); /* Print Hello World */
refresh(); /* Print it on to the real screen */
getch(); /* Wait for user input */
endwin(); /* End curses mode */
return 0;
但在尝试编译代码后出现以下错误:
||=== Build: Debug in pdcurs_test (compiler: GNU GCC Compiler) ===|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcscrn.o):pdcscrn.c|| undefined reference to `GetStockObject@4'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcscrn.o):pdcscrn.c|| undefined reference to `SelectObject@8'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcscrn.o):pdcscrn.c|| undefined reference to `GetStockObject@4'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcscrn.o):pdcscrn.c|| undefined reference to `SelectObject@8'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcscrn.o):pdcscrn.c|| undefined reference to `SelectObject@8'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcscrn.o):pdcscrn.c|| undefined reference to `Rectangle@20'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcscrn.o):pdcscrn.c|| undefined reference to `Rectangle@20'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcscrn.o):pdcscrn.c|| undefined reference to `GetStockObject@4'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcscrn.o):pdcscrn.c|| undefined reference to `SelectObject@8'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcscrn.o):pdcscrn.c|| undefined reference to `GetTextMetricsW@8'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcscrn.o):pdcscrn.c|| undefined reference to `SelectObject@8'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcscrn.o):pdcscrn.c|| undefined reference to `DeleteObject@4'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcscrn.o):pdcscrn.c|| undefined reference to `SelectObject@8'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcscrn.o):pdcscrn.c|| undefined reference to `GetTextMetricsW@8'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcscrn.o):pdcscrn.c|| undefined reference to `SelectObject@8'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcscrn.o):pdcscrn.c|| undefined reference to `DeleteObject@4'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcdisp.o):pdcdisp.c|| undefined reference to `DeleteObject@4'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcdisp.o):pdcdisp.c|| undefined reference to `CreateFontIndirectW@4'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcdisp.o):pdcdisp.c|| undefined reference to `ChooseFontW@4'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcdisp.o):pdcdisp.c|| undefined reference to `CommDlgExtendedError@0'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcdisp.o):pdcdisp.c|| undefined reference to `SetTextColor@8'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcdisp.o):pdcdisp.c|| undefined reference to `SetBkColor@8'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcdisp.o):pdcdisp.c|| undefined reference to `SelectObject@8'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcdisp.o):pdcdisp.c|| undefined reference to `ExtTextOutW@32'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcdisp.o):pdcdisp.c|| undefined reference to `CreatePen@12'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcdisp.o):pdcdisp.c|| undefined reference to `SelectObject@8'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcdisp.o):pdcdisp.c|| undefined reference to `MoveToEx@16'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcdisp.o):pdcdisp.c|| undefined reference to `LineTo@12'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcdisp.o):pdcdisp.c|| undefined reference to `MoveToEx@16'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcdisp.o):pdcdisp.c|| undefined reference to `LineTo@12'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcdisp.o):pdcdisp.c|| undefined reference to `SelectObject@8'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcdisp.o):pdcdisp.c|| undefined reference to `DeleteObject@4'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcdisp.o):pdcdisp.c|| undefined reference to `SelectObject@8'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcdisp.o):pdcdisp.c|| undefined reference to `MoveToEx@16'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcdisp.o):pdcdisp.c|| undefined reference to `LineTo@12'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcdisp.o):pdcdisp.c|| undefined reference to `MoveToEx@16'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcdisp.o):pdcdisp.c|| undefined reference to `LineTo@12'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcdisp.o):pdcdisp.c|| undefined reference to `MoveToEx@16'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcdisp.o):pdcdisp.c|| undefined reference to `LineTo@12'|
C:\Program Files (x86)\CodeBlocks\PDCurses-master\wingui\pdcurses.a(pdcdisp.o):pdcdisp.c|| undefined reference to `DeleteObject@4'|
||error: ld returned 1 exit status|
||=== Build failed: 41 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
在网上搜索解决方案后,我发现我必须在链接器选项中使用 -lgdi32 链接 gdi32 库,但这似乎不起作用。我还尝试使用
包含 windows.h 库#include <windows.h>
在代码的开头,但再次无济于事。
我什至可以使用 C 来使用 Windows GUI,还是需要使用 C++?
是因为我在制作 Makefile 或链接库时出错而产生的错误,我是否需要安装另一个库,还是只是我仍然不知道?
感谢所有建议。
【问题讨论】:
【参考方案1】:我自己的问题已经解决了。
我错误地链接了 gdi32 库。
对于有同样问题的人,请访问:
设置 > 编译器 > 链接器设置 > 链接库 > 添加 >
并找到 libgdi32.a(我的位于 C:\Program Files (x86)\CodeBlocks\MinGW\lib)
【讨论】:
以上是关于尝试使用 pdcurses 扩展库时出现与 gdi32 相关的错误的主要内容,如果未能解决你的问题,请参考以下文章
Windows终端屏幕显示库Public Domain Curses(PDCurses)使用
使用comfort_mexican_sofa 时出现与Turbolinks 相关的错误
在与SQL Server建立连接时出现与网络相关的或特定实例的错误
在codeigniter中安装summernote时出现与jquery相关的错误