我正在编写一个使用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。我做错了什么?
发布于 2018-02-12 13:26:25
使用-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 -lpdcurseshttps://stackoverflow.com/questions/48736097
复制相似问题