macOS (OSX) 上的 ncurses 找不到 xterm-256color

ncurses on macOS (OSX) cannot find xterm-256color

我正在尝试在 macOS 上使用 ncurses 6.0。我已经下载了该项目并使用提供的 makefile 构建了 C++ 演示。但是,当我 运行 演示时,出现错误:

Error opening terminal: xterm-256color.

这可能是相关的:我的 terminfo 目录中没有 x 文件夹:

$ ls /usr/share/terminfo/
31  36  45  51  64  69  6e  73  78
32  37  4c  58  65  6a  6f  74  7a
33  38  4d  61  66  6b  70  75
34  39  4e  62  67  6c  71  76
35  41  50  63  68  6d  72  77

该演示在 Debian 上运行正常。


我的配置输出是:

** Configuration summary for NCURSES 6.0 20150808:

       extended funcs: yes
       xterm terminfo: xterm-new

        bin directory: /usr/local/bin
        lib directory: /usr/local/lib
    include directory: /usr/local/include/ncurses
        man directory: /usr/local/share/man
   terminfo directory: /usr/local/share/terminfo

** Include-directory is not in a standard location

因为我很懒而且不看手册,所以我没有 运行 完整的设置过程。 运行宁之后:

./configure
make
make install

现在可以了。

构建 ncurses 时,configure 脚本会在最后告诉您安装位置。如果你在 OSX 上没有给出任何选项,它将看起来像这样:

creating headers.sh

** Configuration summary for NCURSES 6.0 20160409:

       extended funcs: yes
       xterm terminfo: xterm-new

        bin directory: /usr/local/bin
        lib directory: /usr/local/lib
    include directory: /usr/local/include/ncurses
        man directory: /usr/local/share/man
   terminfo directory: /usr/local/share/terminfo

** Include-directory is not in a standard location

您可以覆盖 terminfo 目录的位置(阅读 INSTALL file), or tell the library at runtime by setting the TERMINFO and/or TERMINFO_DIRS 环境变量。但如果不执行其中任何一项操作,它将在不同的位置查找终端数据库。

ncurses 配置脚本为某些系统(主要是基于 Linux 的系统)提供了一个 --prefix=/usr 选项,因为它应该是系统 curses 库(再次阅读 INSTALL) . OSX这里不是奇数

OSX 与通常情况不同:它的文件系统(通常)忽略 upper/lowercase 名称之间的差异。配置脚本会检查这一点,如果是,它会编译成一种变通方法,将这些单个字母编码为十六进制数。例如,0x78 是 "x".