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

标签 c++ macos ncurses

我正在尝试在 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 时,配置脚本会在最后告诉您它将安装在哪里。如果您在 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 文件),或者通过设置 TERMINFO 在运行时告诉库。和/或 TERMINFO_DIRS环境变量。但如果不执行其中一项操作,它将在不同位置查找终端数据库。

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

OSX 与通常情况不同:它的文件系统(通常)忽略大小写名称之间的差异。配置脚本会检查这一点,如果是这样,它会编译一个解决方法,将这些单个字母编码为十六进制数字。例如,0x78 是“x”。

关于c++ - macOS (OSX) 上的 ncurses 找不到 xterm-256color,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39832646/

相关文章:

python - 使用 Python curses 自定义 RGB 颜色

c++ - 静态库 - 使用自己的 Qt .so 文件的静态库

c++ - 使用 C/C++ 添加用户到 MySQL

swift - 创建 plist 并将其复制到文件夹 MacOS Swift

javascript - 组合 Keydown 功能不适用于 Mac 键盘

c - 使用 Ncurses 绘制方框

c - 使用 ncurses 调整终端大小和滚动问题

c++ - 从命令行使用范围

c++ - 如何将元组 <> 剥离回可变参数模板类型列表?

macos - 在 NSAlert 中单击按钮的 AppleScript 代码