Lady777 wrote:
-> How can I add /usr/lib/libncurses.dylib to my project? What does he mean by "link against the library"? I type #include <curses.h> in my code but what else should I do to "link against the library"?
When you build an executable from a compiled language (such as C, C++, Objective-C, and others) it basically involves two steps. A compile phase and a link phase. As a simple explanation...
Compiling takes the source code files you've created, checks to make sure they are syntactically correct and then produces _object code_ files for each of your source code files. At this point these object code files are not executable because they only include code for what _you have written_ and not any of the functionality provided by the OS.
When you #include a .h file in one of your source files it allows the compile step to verify that your use of functions defined in the .h file are
syntactically correct. But it doesn't include any executable code for those functions.
Then the link step takes the object code files produced by the compile step and links them together along with object code libraries provided by the OS to produce your final executable file. To "link against a library" means that you add the (system provided) library to the list of libraries that gets used during this link step.
When you do a "build" in Xcode it does both a compile and a link for you. So it's possible to fail during the compile step if your source code contains errors. But it's also possible to successfully compile if your code is syntactically correct but then fail during the link step if the linker can't resolve references to external functions.
To add /usr/lib/libcurses.dylib in Xcode go to "Project -> Add to project...". Since the /usr directory is typically invisible in Finder you probably won't see it in the Add window... instead, while the Add window is open press Command-Shift-G. This will open a "Go to folder" window. Type in /usr/lib and click OK. You should then see all the libraries available in /usr/lib. Select libcurses.dylib and click the Add button.
Steve