2012-11-05 56 views
6

我寫了一個hello world程序來查看curses庫是如何工作的。無法使用gcc(OS X)上的curses進行編譯

這裏是我的程序:

/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; 
} 

我跑gcc main.c

/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 

我沒有什麼錯。任何人都可以幫忙嗎?

回答

17

沒關係。編譯時我不得不添加-lcurses選項。