problem using curses.h

hi,
i got NCurses.h (which includes curses.h, term.h and many others) through command
$ sudo apt-get install libncurses5-dev libncursesw5-dev
it downloaded and is appearing in netbeans 6.9 ide's intellisense when including it. But the ide is putting a red line under it saying no such library exists although it predicts it. And when functions of this library are called, ide says undefined reference to XYZfunction.
for example i tried using it in this way
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
int main()
  {
  char users_name[ 100 ];

  initscr();
  (void)echo();

  addstr( "What is your name> " );
  refresh();
  getnstr( users_name, sizeof( users_name ) - 1 );

  clear();

  printw( "Greetings and salutations %s!\n", users_name );
  refresh();

  printw( "\n\n\nPress ENTER to quit." );
  refresh();
  getnstr( users_name, sizeof( users_name ) - 1 );

  endwin();
  return 0;
}


and errors are
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
mkdir -p dist/Debug/GNU-Linux-x86
g++     -o dist/Debug/GNU-Linux-x86/net_test build/Debug/GNU-Linux-x86/main.o  
make[2]: Leaving directory `/host/dan/practice/net test'
make[1]: Leaving directory `/host/dan/practice/net test'
build/Debug/GNU-Linux-x86/main.o: In function `main':
/host/dan/practice/net test/main.cpp:256: undefined reference to `initscr'
/host/dan/practice/net test/main.cpp:257: undefined reference to `echo'
/host/dan/practice/net test/main.cpp:259: undefined reference to `stdscr'
/host/dan/practice/net test/main.cpp:259: undefined reference to `waddnstr'
/host/dan/practice/net test/main.cpp:260: undefined reference to `refresh'
/host/dan/practice/net test/main.cpp:261: undefined reference to `stdscr'
/host/dan/practice/net test/main.cpp:261: undefined reference to `wgetnstr'
/host/dan/practice/net test/main.cpp:263: undefined reference to `clear'
/host/dan/practice/net test/main.cpp:265: undefined reference to `printw'
/host/dan/practice/net test/main.cpp:266: undefined reference to `refresh'
/host/dan/practice/net test/main.cpp:268: undefined reference to `printw'
/host/dan/practice/net test/main.cpp:269: undefined reference to `refresh'
/host/dan/practice/net test/main.cpp:270: undefined reference to `stdscr'
/host/dan/practice/net test/main.cpp:270: undefined reference to `wgetnstr'
/host/dan/practice/net test/main.cpp:272: undefined reference to `endwin'
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-Linux-x86/net_test] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 1s)

can anyone tell how this/these issues can b resolved. I am in heap of trouble, coz tomorrow is deadline of my project submission.
Last edited on
man ncurses wrote:
#include <curses.h>
A program using these routines must be linked with the -lncurses option, or (if it has been generated) with the debugging library -lncurses_g.

Check your IDE documentation.
i am newbie..... can you explain me further?
-regards
I don't really know about IDE's so bare with me. First you should try to compile your work in console as follows:
g++ <all necessary c++ files> -lncurses
if that works you should check that your IDE passes argument "-lncurses" during compilation.

EDIT:
g++ -o dist/Debug/GNU-Linux-x86/net_test build/Debug/GNU-Linux-x86/main.o
that is compilation and there is no "-lncurses" ;)
Last edited on
Topic archived. No new replies allowed.