无法正确编译抛出 makefile:[...]:对“__imp_stdscr”的未定义引用

Can't compile correctly throw makefile: [...]: undefined reference to `__imp_stdscr'

提问人:pietro ventrucci 提问时间:11/4/2021 最后编辑:pietro ventrucci 更新时间:11/5/2021 访问量:107

问:

我试图通过 编译文件。该文件不是我的,我不完全理解它,但我必须编译它。我知道我在使用诅咒,而且我在 Windows 上。make

这是 makefile:

CFLAG = -Wall -pedantic -Wno-comment -O3 -std=c89
  
all: pong pong_log

game.o: game.h game.c
    gcc $(CFLAG) -c game.c

display.o: display.h display.c
    gcc $(CFLAG) -c display.c

pong: game.h display.h game.o display.o main.c
    gcc $(CFLAG) display.o game.o main.c -o pong -lncurses

pong_log: game.h display.h game.o display.o main.c
    gcc $(CFLAG) -D REG display.o game.o main.c -o pong_log -lncurses 

clean:
    rm -rf *.o pong pong_log

我得到的错误是:

gcc -Wall -pedantic -Wno-comment -O3 -std=c89 display.o game.o main.c -o pong -lncurses
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: display.o:display.c:(.text+0x1f): undefined reference to `__imp_stdscr'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: display.o:display.c:(.text+0x302): undefined reference to `__imp_stdscr'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: display.o:display.c:(.text+0xbb8): undefined reference to `__imp_stdscr'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: display.o:display.c:(.text+0xc85): undefined reference to `__imp_stdscr'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: display.o:display.c:(.text+0xcb3): undefined reference to `__imp_stdscr'
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile:12: pong] Error 1
c makefile 未定义引用 诅咒

评论

2赞 Andreas 11/4/2021
尝试在链接 ncurses 时添加:stackoverflow.com/a/11269810/6121044-ltinfo
0赞 John Bollinger 11/4/2021
正如你所展示的那样,你的makefile有点混乱。至少,删除了一些换行符。我假设这是在在此处发布代码的过程中发生的,因为显示的诊断消息与给定格式的 makefile 不一致。
0赞 pietro ventrucci 11/5/2021
现在@JohnBollinger是正确的
0赞 pietro ventrucci 11/5/2021
@Andreas 我对 C 不太擅长,所以我在行的末尾尝试 ad -ltinfo,但它找不到它

答: 暂无答案