【问题标题】:libpdcurses.a setting for PdcursesPdcurses 的 libpdcurses.a 设置
【发布时间】:2018-07-22 00:15:03
【问题描述】:

我正在开发一个程序,其中我使用 i686-w64-mingw32-gcc.exe 使用 PDCurses3.5 函数。 当我编译程序时,我不断收到诸如"undefined reference to 'COLS'""undefined reference to 'lines'" 之类的错误。 我检查了<curses.h> 标头和库包是否正确安装。 这是我的输入行:

> i686-w64-mingw32-gcc.exe set.o read.o elements.o random.o
> -L../standard/test -lplotfit -lplotget -lgfortran -Wl,--subsystem,console -mwindows -o runtime/mingw/result -lm -static -lws2_32  -lpdcurses

错误的第一部分是:

../standard/bin/mingw/menu.o:menu.c:(.text+0xb): undefined reference to `COLS' 
../standard/bin/mingw/menu.o:menu.c:(.text+0x16): undefined reference to `COLS' 
../standard/bin/mingw/menu.o:menu.c:(.text+0x33): undefined reference to `LINES' 
../standard/bin/mingw/menu.o:menu.c:(.text+0x47): undefined reference to `MOVE' 
../standard/bin/mingw/menu.o:menu.c:(.text+0x74): undefined reference to `initscr'
...

该程序似乎无法在其库文件中引用 libpdcurses.a。 我做错了什么?

【问题讨论】:

标签: c linker-errors undefined-reference pdcurses


【解决方案1】:

当您使用-lpdcurses 时,链接器会在某些预定义位置以及通过-L 指定的位置中查找libpdcurses.a。但是,默认情况下,该库构建为pdcurses.a。要链接它,您可以直接指定它的位置;例如:

gcc -oprogname.exe progname.c pdcurses.a

gcc -oprog2.exe prog2.c /pdcurses/win32/pdcurses.a

或者,您可以将库重命名为 libpdcurses.a,然后将其复制到现有搜索路径中的某个位置,或使用 -L

gcc -oprogname.exe progname.c -lpdcurses

gcc -oprog2.exe prog2.c -L/pdcurses/win32 -lpdcurses

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-25
    • 2018-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多