0

I have this code:

#include <stdio.h>
#include <termcap.h>
#include <stdlib.h>

int main() {
    char *termtype = getenv("TERM");
    int li = tgetnum("li");
    printf("%d", li);
    return 0;
}

I can't compile it because I get

    Undefined symbols for architecture x86_64:
      "_tgetnum", referenced from:
          _main in main-11560e.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

Why is it happening?
MacOS Catalina

MHDtA
  • 21
  • 1
  • 1
    Does this answer your question? [Compiling a .C file: Undefined symbols for architecture x86\_64](https://stackoverflow.com/questions/19572665/compiling-a-c-file-undefined-symbols-for-architecture-x86-64) – SergeyA Dec 08 '21 at 20:18
  • I have compiled my program with -c flag, but it refuses to run. "cannot execute binary file" – MHDtA Dec 08 '21 at 20:23
  • You left out `-lncurses` on the command-line (this is a duplicate). – Thomas Dickey Dec 10 '21 at 01:09

0 Answers0