我正在运行Ubuntu 12.04,我目前正在开发一个涉及C,OpenGL,茶壶和输入法的项目.
当我决定使用箭头键作为输入时,问题就出现了.我检查了箭头键的键代码,但所有箭头都返回0.我查找了如何使这个工作,我找到了conio.h.不幸的是,它是一个旧的DOS标头,不适用于Linux.然后我找到了一个名为ncurses的替代品.
安装必要的库后,按照构建说明,我在main.c源代码中使用#included curses.h.当我第一次尝试使用gcc编译时,我收到以下错误:
main.o:main.c:function _Key: error: undefined reference to 'stdscr'
main.o:main.c:function _Key: error: undefined reference to 'wgetch'
main.o:main.c:function _Key: error: undefined reference to 'stdscr'
main.o:main.c:function _Key: error: undefined reference to 'wgetch'
Run Code Online (Sandbox Code Playgroud)
我通过将-lncurses添加到makefile中找到了修复,如下所示:
SOURCES=main.c
main: main.o
gcc -lm -lGL -lGLU -lglut -lncurses main.o -o main
main.o: main.c
gcc -lm -lGL -lGLU -lglut -c main.c
Run Code Online (Sandbox Code Playgroud)
但是另一个错误让我受到了欢迎:
/usr/bin/ld: error: cannot find -lncurses
Run Code Online (Sandbox Code Playgroud)
以及以前的错误.
我花了最近两天的时间搜索Ubuntu论坛和StackOverFlow.任何帮助,将不胜感激.
PS我不知道这是否重要但是当我尝试运行/ usr/bin/ld时出现此错误:
ld: fatal error: no input files
Run Code Online (Sandbox Code Playgroud)