5

I'm trying to compile ncurses based app on Mac OS X 10.6.8 but I get this error.

Undefined symbols for architecture x86_64:
  "_initscr", referenced from:
      _main in ccf8K8YG.o
  "_printw", referenced from:
      _main in ccf8K8YG.o
  "_stdscr", referenced from:
      _main in ccf8K8YG.o
  "_wrefresh", referenced from:
      _main in ccf8K8YG.o
  "_wgetch", referenced from:
      _main in ccf8K8YG.o
  "_endwin", referenced from:
      _main in ccf8K8YG.o

What could be the problem ?

mrflash818
  • 930
  • 13
  • 24
johe
  • 63
  • 4
  • Are the libraries you are trying to link against in x86_64 format? Can you try to build your application in x86 format and see if it makes any difference? – HonkyTonk Aug 14 '12 at 14:26
  • 6
    What linker options are you using? Have you got the app to run on another platform (eg linux) or has it never compiled? You'll need some argument `-lncurses` in the final stage when you generate your executable (or else load the ncurses functions dynamically). – Nicholas Wilson Aug 14 '12 at 17:48

1 Answers1

4

I'm pretty sure this is because you're not including the ncurses library when compiling.

Try adding:

-lncurses

when compiling.

For example (for C++):

g++ -o hello main.cpp -lncurses

Or using gcc (for C):

gcc -o hello main.cpp -lncurses

This short command will compile and execute:

gcc -o hello main.cpp -lncurses && ./hello

This was my issue, I hope this helps someone.

jenkizenki
  • 741
  • 6
  • 14