the program is from
Linux.org
Code:
#include <ncurses.h>
int main()
{ int ch;
initscr(); /* Start curses mode */
raw(); /* Line buffering disabled */
keypad(stdscr, TRUE); /* We get F1, F2 etc.. */
noecho(); /* Don't echo() while we do getch */
printw("Type any character to see it in bold\n");
ch = getch(); /* If raw() hadn't been called
* we have to press enter before it
* gets to the program */
if(ch == KEY_F(1)) /* Without keypad enabled this will */
printw("F1 Key pressed");/* not get to us either */
/* Without noecho() some ugly escape
* charachters might have been printed
* on screen */
else
{ printw("The pressed key is ");
attron(A_BOLD);
printw("%c", ch);
attroff(A_BOLD);
}
refresh(); /* Print it on to the real screen */
getch(); /* Wait for user input */
endwin(); /* End curses mode */
return 0;
}
on compiling the program, the shell displays the following error:
[ryland@localhost compiler]$ gcc -o testncurses.o testncurses.c
/tmp/cceWHfdn.o(.text+0x11): In function `main':
: undefined reference to `initscr'
/tmp/cceWHfdn.o(.text+0x16): In function `main':
: undefined reference to `raw'
/tmp/cceWHfdn.o(.text+0x21): In function `main':
: undefined reference to `stdscr'
/tmp/cceWHfdn.o(.text+0x26): In function `main':
: undefined reference to `keypad'
/tmp/cceWHfdn.o(.text+0x2e): In function `main':
: undefined reference to `noecho'
/tmp/cceWHfdn.o(.text+0x3b): In function `main':
: undefined reference to `printw'
/tmp/cceWHfdn.o(.text+0x47): In function `main':
: undefined reference to `stdscr'
/tmp/cceWHfdn.o(.text+0x4c): In function `main':
: undefined reference to `wgetch'
/tmp/cceWHfdn.o(.text+0x68): In function `main':
: undefined reference to `printw'
/tmp/cceWHfdn.o(.text+0x7a): In function `main':
: undefined reference to `printw'
/tmp/cceWHfdn.o(.text+0x8d): In function `main':
: undefined reference to `stdscr'
/tmp/cceWHfdn.o(.text+0x92): In function `main':
: undefined reference to `wattr_on'
/tmp/cceWHfdn.o(.text+0xa5): In function `main':
: undefined reference to `printw'
/tmp/cceWHfdn.o(.text+0xb8): In function `main':
: undefined reference to `stdscr'
/tmp/cceWHfdn.o(.text+0xbd): In function `main':
: undefined reference to `wattr_off'
/tmp/cceWHfdn.o(.text+0xc9): In function `main':
: undefined reference to `stdscr'
/tmp/cceWHfdn.o(.text+0xce): In function `main':
: undefined reference to `wrefresh'
/tmp/cceWHfdn.o(.text+0xda): In function `main':
: undefined reference to `stdscr'
/tmp/cceWHfdn.o(.text+0xdf): In function `main':
: undefined reference to `wgetch'
/tmp/cceWHfdn.o(.text+0xe7): In function `main':
: undefined reference to `endwin'
collect2: ld returned 1 exit status
[ryland@localhost compiler]$
but I indeed include the ncurses library. How to solve this problem?thanks.