tags:

views:

46

answers:

2

WHen I compile this code, it shows me linker error

#include <curses.h>
#include <ncurses.h>

int main()
{   int ch;

    raw();    /* Line buffering disabled */
}

Compiler error:

/tmp/ccY9Bug1.o: In function `main':
raw.c:(.text+0x12): undefined reference to `raw'
collect2: ld returned 1 exit status

I have checked that curses.h anf ncurses.h exists in /usr/include directory and there is even man page for raw on my linux system. Please tell me how to correct this error.

+1  A: 

Pass "-lcurses" or "-lncurses" or something like that to the linker.

gcc foo.c -lcurses

works for me.

Paul Tomblin
+1  A: 

You need to link with curses or ncurses library:

gcc yourcode.c -lcurses -lncurses

coelhudo