I am compiling a program which creates window on shell. When I compile I get errors like
开发者_如何学Gotest.c:(.text+0x25): undefined reference to `newwin'
test.c:(.text+0x73): undefined reference to `wborder'
test.c:(.text+0xb6): undefined reference to `mvwprintw'
..
..
One of my functions is
WINDOW *f_top, *f_bottom;
WINDOW *create_window(int n, int d, char *t){
WINDOW *frame;
WINDOW *w;
frame = newwin(n, COLS, d, 0);
box(frame,0,0);
mvwprintw(frame,0,COLS/2-strlen(t)/2,t);
wrefresh(frame);
w = newwin(n-2, COLS-2, d+1, 1);
idlok(w, TRUE);
scrollok(w, TRUE);
wclear(w);
wrefresh(w);
return w;
}
You need to link with the curses library. The functions are defined there.
Try
gcc ... test.c ... -lcurses ...
or maybe
gcc ... test.c ... -lncurses ...
To be more explicit,
Firstly you need to install the curses (or ncurses) library if required.
Secondly, include curses.h
Thirdly, these need to be found, you may have issues with the $PATH.
Finally, depending on how much later this is being read, there may be 'deprecated' functions. - search curses.h (and then the web) for the the names.
Typically for a 64 bit Linux installation, the assets involved might be found in :
/usr/lib/x86_64-linux-gnu/libncurses.so
/usr/include/curses.h
精彩评论