help installing ncurses (mac)

I am trying this simple ncurses program, and I get an error I cannot interpret.
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <ncurses.h>
#include <iostream>
using namespace std;

int main() {
	initscr();
	printw("Hello, world!");
	refresh();
	getch();
	endwin();
	return 0;
}


/bin/sh -c '/usr/bin/make -j4 -e -f  Makefile'
----------Building project:[ Beads - Debug ]----------
/usr/bin/g++   -c  "/Users/Nihar/C++/beadsGame/main.cpp" -g -O0 -Wall  -o ./Debug/main.cpp.o -I. -I.
/usr/bin/g++  -o ./Debug/Beads @"Beads.txt" -L.
Undefined symbols for architecture x86_64:
  "_endwin", referenced from:
      _main in main.cpp.o
  "_initscr", referenced from:
      _main in main.cpp.o
  "_printw", referenced from:
      _main in main.cpp.o
  "_refresh", referenced from:
      _main in main.cpp.o
  "_stdscr", referenced from:
      _main in main.cpp.o
  "_wgetch", referenced from:
      _main in main.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [Debug/Beads] Error 1
make: *** [All] Error 2
1 errors, 0 warnings


Help is appreciated, thanks!
Last edited on
You forgot to link with libcurses.
Will you please explain what that is and where to find it?
All the code that does stuff is in a "library" somewhere -- code that has already been compiled and ready to link to your program -- either as part of your final executable/binary or as a dynamic link file (".so" on OSX).

Functions and stuff that comes with C++ (things like cout, printf(), etc) is automatically linked for you. Stuff that does not come with it (like NCurses functions: wprintf(), etc) is not. You need to tell the compiler/linker where to find the library file so that it can be linked to the code you wrote.

https://developer.apple.com/library/ios/recipes/xcode_help-project_editor/Articles/AddingaLibrarytoaTarget.html

http://stackoverflow.com/questions/445815/linking-libraries-in-xcode

Hope this helps.
thanks!
Topic archived. No new replies allowed.