Problema con librerie. NCURSES

Postate qui per tutte le discussioni legate a Linux in generale.

Moderatore: Staff

Regole del forum
1) Citare sempre la versione di Slackware usata, la versione del Kernel e magari anche la versione della libreria coinvolta. Questi dati aiutano le persone che possono rispondere.
2) Per evitare confusione prego inserire in questo forum solo topic che riguardano appunto Gnu/Linux in genere, se l'argomento è specifico alla Slackware usate uno dei forum Slackware o Slackware64.
3) Leggere attentamente le risposte ricevute
4) Scrivere i messaggi con il colore di default, evitare altri colori.
5) Scrivere in Italiano o in Inglese, se possibile grammaticalmente corretto, evitate stili di scrittura poco chiari, quindi nessuna abbreviazione tipo telegramma o scrittura stile SMS o CHAT.
6) Appena registrati è consigliato presentarsi nel forum dedicato.

La non osservanza delle regole porta a provvedimenti di vari tipo da parte dello staff, in particolare la non osservanza della regola 5 porta alla cancellazione del post e alla segnalazione dell'utente. In caso di recidività l'utente rischia il ban temporaneo.
Rispondi
Avatar utente
Infrid
Linux 1.x
Linux 1.x
Messaggi: 198
Iscritto il: mar 8 nov 2005, 12:46
Contatta:

Problema con librerie. NCURSES

Messaggio da Infrid »

salve a tutti,
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);
}
mi restituisce questo output che proprio non capisco

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
eppure le librerie sembrano installate correttamente, altrimeti mi direbbe che non trova il file ncurses.h

qualcuno ha qualche idea?

grazie

ciao
Ultima modifica di Infrid il dom 13 ago 2006, 9:19, modificato 1 volta in totale.

gastone90

Messaggio da gastone90 »

prova a postare su http://www.progforum.it ... ;)

Avatar utente
albatros
Iper Master
Iper Master
Messaggi: 2098
Iscritto il: sab 4 feb 2006, 13:59
Kernel: 6.18.0
Desktop: gnome and lxqt
Distribuzione: Ubuntu 24.04 & FC 41
Località: Darmstadt - Germania

Messaggio da albatros »

ldconfig?

Avatar utente
Luci0
Staff
Staff
Messaggi: 3591
Iscritto il: lun 27 giu 2005, 0:00
Nome Cognome: Gabriele Santanché
Slackware: 12.2 14.0
Kernel: 2.6.27.46- gen 3.2.29
Desktop: KDE 3.5.10 Xfce
Località: Forte dei Marmi
Contatta:

Messaggio da Luci0 »

ncurses... no NURSES!!!
io credevo un nproblema tipo questo ...
http://www.dimout.com/sexy-nurse-costumes.html

... ma adesso ho capito !!

gastone90

Messaggio da gastone90 »

:o :lol:

Avatar utente
Infrid
Linux 1.x
Linux 1.x
Messaggi: 198
Iscritto il: mar 8 nov 2005, 12:46
Contatta:

Messaggio da Infrid »

Luci0 ha scritto:ncurses... no NURSES!!!
io credevo un nproblema tipo questo ...
http://www.dimout.com/sexy-nurse-costumes.html

... ma adesso ho capito !!
ho editato il titolo Immagine
più tardi proverò con ldconfig

----edit

il problema rimane anche dopo ldconfig :(

gastone90

Messaggio da gastone90 »

prova a postare su http://www.progforum.it .. visto che è un forum apposta per programmatori ;)

Avatar utente
tgmx
Linux 4.x
Linux 4.x
Messaggi: 1336
Iscritto il: ven 28 apr 2006, 14:40
Slackware: 14.1
Desktop: KDE 4
Località: Ancona

Messaggio da tgmx »

Hai passato a gcc "-lncurses" ?

Avatar utente
Infrid
Linux 1.x
Linux 1.x
Messaggi: 198
Iscritto il: mar 8 nov 2005, 12:46
Contatta:

Messaggio da Infrid »

non avevo pasato al gcc -lncurses

tutto risolto
grazie :D

Rispondi