0

我正在开发一个程序,在该程序中我使用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。我究竟做错了什么?

4

1 回答 1

0

当您使用-lpdcurses时,链接器libpdcurses.a会在某些预定义位置以及通过-L. 但是,默认情况下,该库构建为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
于 2018-02-12T13:26:25.793 回答