Link Error

I'm running Xcode 12.4 on an M1 Mac Mini with command line tools installed. My project was created as a macOS "Command Line Tool" application. When I try to build:

#include <term.h>

int main(int argc, const char * argv[]) {
    set_curterm(nullptr);
    return 0;
}

I get the following linker error:

Undefined symbols for architecture arm64:
  "_set_curterm", referenced from:
      _main in main.o

Does anyone know what library I need to link to in order to resolve _set_curterm?
Answered by DTS Engineer in 670114022

Is there some way I could have used documentation to figure that out
without guessing?

Kinda. Xcode help does cover the process for linking to a framework or a library. The problem is that there’s no clear link between the set_curterm function and the libcurses library. This is one of the things that falls in the cracks between Apple stuff and UNIX-y stuff. Most folks who use curses are coming from a UNIX background where adding -lcurses to their linker invocation is common knowledge.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
The solution I finally stumbled upon was to use "Link Binary With Libraries" to add libcurses.tbd to the project. I'm new to Xcode, but I have to ask: Is there some way I could have used documentation to figure that out without guessing?
Accepted Answer

Is there some way I could have used documentation to figure that out
without guessing?

Kinda. Xcode help does cover the process for linking to a framework or a library. The problem is that there’s no clear link between the set_curterm function and the libcurses library. This is one of the things that falls in the cracks between Apple stuff and UNIX-y stuff. Most folks who use curses are coming from a UNIX background where adding -lcurses to their linker invocation is common knowledge.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
Thank you eskimo. I was compiling/linking a file based upon the Clang static analyzer and seeing unresolved references to curses and zlib functions. This is my first foray into using Clang LibTools and I'm not historically a big Unix user, so it took me a little while to discover the semantics of those functions and then realize I needed to go searching for their respective libraries and guessing which ones would contain their definitions.
Link Error
 
 
Q