For the readline() exercise, we needed to add libreadline.dylib before we could import readline.h. However, we would not need to add a library for <stdio.h>. Is there a list of what is already available by default so it is clear when a new library needs to be added?
I believe because readline is not a part of the Standard C library, but is included on our Macs, you need to explicitly add it in the Xcode project settings.
What is the difference between adding libreadline the way we did versus using #include or #import the way we have been doing so far? Why was this done differently?
We use #include and #import in Objective-C to allow the compiler to see the declarations of things before we start using those things the program we are writing.
We add libraries to a project to allow the linker to find the definitions (in compiled, binary form) of those things when it is building the binary executable file for our program.
In some cases, Xcode doesn’t tell the linker where to find the libraries or frameworks containing definitions (in compiled, binary form). The readline-example project is one of those cases, and that’s why you have to explicitly add the library to your project.
[Become a competent programmer: pretty-function.org]
Just read this response. I had already asked you a similar question in another thread, so sorry for that.
How does one learn about all these available resources?
And if I understand your answer above, is the reason that Spotlight doesn’t find any reference to readline, because the library we added in Xcode is binary?
I guess this knowledge of what is available and how to link it comes with years of experience, huh?
By research and practice, not without pains.
Yes, but Spotlight should still be able to find the header files exported by the library.