Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not able to compile with curses on gcc (OS X))

I wrote a hello world program to see how curses library works.

Here is my program:

/Users/snihalani/dev/daas at 10:10AM 
➜ cat main.c 
#include <stdio.h>
#include <stdlib.h>
#include <curses.h>

int main(void)
{
    int returnValue = 0;
    while(1)
    {
        printf("I got %d\n", getch());
    }
    return 0;
}

I ran gcc main.c

I got

/Users/snihalani/dev/daas at 10:14AM 
➜ gcc main.c 
Undefined symbols for architecture x86_64:
  "_stdscr", referenced from:
      _main in ccEvUdhx.o
  "_wgetch", referenced from:
      _main in ccEvUdhx.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

I don't what's going wrong. Can anyone please help?

like image 875
SurenNihalani Avatar asked Nov 05 '12 15:11

SurenNihalani


1 Answers

Nevermind. I had to add -lcurses option while compiling.

like image 137
SurenNihalani Avatar answered Oct 16 '22 03:10

SurenNihalani