SurenNihalani
SurenNihalani

Reputation: 1438

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?

Upvotes: 14

Views: 5391

Answers (1)

SurenNihalani
SurenNihalani

Reputation: 1438

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

Upvotes: 28

Related Questions