ho installato le librerie ncurses e cdk, ma compilando il seguete programma
Codice: Seleziona tutto
#include <stdio.h>
#include <curses.h>
#define WIDTH 30
#define HEIGHT 10 
int startx = 0;
int starty = 0;
char *choices[] = { 
			"Choice 1",
			"Choice 2",
			"Choice 3",
			"Choice 4",
			"Exit",
		  };
int n_choices = sizeof(choices) / sizeof(char *);
void print_menu(WINDOW *menu_win, int highlight);
int main()
{	WINDOW *menu_win;
	int highlight = 1;
	int choice = 0;
	int c;
	initscr();
	clear();
	noecho();
	cbreak();	/* Line buffering disabled. pass on everything */
	startx = (80 - WIDTH) / 2;
	starty = (24 - HEIGHT) / 2;
		
	menu_win = newwin(HEIGHT, WIDTH, starty, startx);
	keypad(menu_win, TRUE);
	mvprintw(0, 0, "Use arrow keys to go up and down, Press enter to select a choice");
	refresh();
	print_menu(menu_win, highlight);
	while(1)
	{	c = wgetch(menu_win);
		switch(c)
		{	case KEY_UP:
				if(highlight == 1)
					highlight = n_choices;
				else
					--highlight;
				break;
			case KEY_DOWN:
				if(highlight == n_choices)
					highlight = 1;
				else 
					++highlight;
				break;
			case 10:
				choice = highlight;
				break;
			default:
				mvprintw(24, 0, "Charcter pressed is = %3d Hopefully it can be printed as '%c'", c, c);
				refresh();
				break;
		}
		print_menu(menu_win, highlight);
		if(choice != 0)	/* User did a choice come out of the infinite loop */
			break;
	}	
	mvprintw(23, 0, "You chose choice %d with choice string %s\n", choice, choices[choice - 1]);
	clrtoeol();
	refresh();
	endwin();
	return 0;
}
void print_menu(WINDOW *menu_win, int highlight)
{
	int x, y, i;	
	x = 2;
	y = 2;
	box(menu_win, 0, 0);
	for(i = 0; i < n_choices; ++i)
	{	if(highlight == i + 1) /* High light the present choice */
		{	wattron(menu_win, A_REVERSE); 
			mvwprintw(menu_win, y, x, "%s", choices[i]);
			wattroff(menu_win, A_REVERSE);
		}
		else
			mvwprintw(menu_win, y, x, "%s", choices[i]);
		++y;
	}
	wrefresh(menu_win);
}Codice: Seleziona tutto
bash-3.00$ gcc prova.c -o prov
/tmp/ccmorsxa.o(.text+0x1f): In function `main':
: undefined reference to `initscr'
/tmp/ccmorsxa.o(.text+0x28): In function `main':
: undefined reference to `stdscr'
/tmp/ccmorsxa.o(.text+0x2d): In function `main':
: undefined reference to `wclear'
/tmp/ccmorsxa.o(.text+0x35): In function `main':
: undefined reference to `noecho'
/tmp/ccmorsxa.o(.text+0x3a): In function `main':
: undefined reference to `cbreak'
/tmp/ccmorsxa.o(.text+0x63): In function `main':
: undefined reference to `newwin'
/tmp/ccmorsxa.o(.text+0x76): In function `main':
: undefined reference to `keypad'
/tmp/ccmorsxa.o(.text+0x8a): In function `main':
: undefined reference to `mvprintw'
/tmp/ccmorsxa.o(.text+0x96): In function `main':
: undefined reference to `stdscr'
/tmp/ccmorsxa.o(.text+0x9b): In function `main':
: undefined reference to `wrefresh'
/tmp/ccmorsxa.o(.text+0xba): In function `main':
: undefined reference to `wgetch'
/tmp/ccmorsxa.o(.text+0x13c): In function `main':
: undefined reference to `mvprintw'
/tmp/ccmorsxa.o(.text+0x148): In function `main':
: undefined reference to `stdscr'
/tmp/ccmorsxa.o(.text+0x14d): In function `main':
: undefined reference to `wrefresh'
/tmp/ccmorsxa.o(.text+0x189): In function `main':
: undefined reference to `mvprintw'
/tmp/ccmorsxa.o(.text+0x195): In function `main':
: undefined reference to `stdscr'
/tmp/ccmorsxa.o(.text+0x19a): In function `main':
: undefined reference to `wclrtoeol'
/tmp/ccmorsxa.o(.text+0x1a6): In function `main':
: undefined reference to `stdscr'
/tmp/ccmorsxa.o(.text+0x1ab): In function `main':
: undefined reference to `wrefresh'
/tmp/ccmorsxa.o(.text+0x1b3): In function `main':
: undefined reference to `endwin'
/tmp/ccmorsxa.o(.text+0x1e9): In function `print_menu':
: undefined reference to `wborder'
/tmp/ccmorsxa.o(.text+0x21e): In function `print_menu':
: undefined reference to `wattr_on'
/tmp/ccmorsxa.o(.text+0x241): In function `print_menu':
: undefined reference to `mvwprintw'
/tmp/ccmorsxa.o(.text+0x256): In function `print_menu':
: undefined reference to `wattr_off'
/tmp/ccmorsxa.o(.text+0x27b): In function `print_menu':
: undefined reference to `mvwprintw'
/tmp/ccmorsxa.o(.text+0x298): In function `print_menu':
: undefined reference to `wrefresh'
collect2: ld returned 1 exit status
qualcuno ha qualche idea?
grazie
ciao






 
  




