编译 Zsh

编译

  1. 安装依赖 ncurses

    sudo yum install -y ncurses-devel
    
  2. zsh.org 下载源码:

    wget https://www.zsh.org/pub/zsh-5.9.tar.xz
    tar -xJf zsh-*.tar.xz && rm zsh-*.tar.xz
    cd zsh-*
    
  3. 编译并安装:

    mkdir build && cd build
    ../configure  # 可设置 --prefix=$HOME/.local
    make -j$(nproc)
    sudo make install
    
  4. 设为默认 Shell(可选):

    echo /usr/local/bin/zsh | sudo tee -a /etc/shells
    chsh -s /usr/local/bin/zsh
    

参考:

Troubleshooting

No terminal handling library was found on your system

configure: error: in `/usr/local/src/zsh-5.9':
configure: error: "No terminal handling library was found on your system.
This is probably a library called 'curses' or 'ncurses'.  You may
need to install a package called 'curses-devel' or 'ncurses-devel' on your
system."
See `config.log' for more details

需要编译 ncurses 库,并将库安装路径添加到 LDFLAGS 环境变量:

export LDFLAGS="-L$HOME/.local/lib $LDFLAGS"

conflicting types for ‘boolcodes’

termcap.c:45:14: error: conflicting types for ‘boolcodes’; have ‘char *[]’
   45 | static char *boolcodes[] = {
      |              ^~~~~~~~~
In file included from ../../Src/zshterm.h:1,
                 from ../../Src/zsh_system.h:932,
                 from ../../Src/zsh.mdh:15,
                 from termcap.mdh:15,
                 from termcap.c:38:
/data2/lx/.local/include/term.h:783:56: note: previous declaration of ‘boolcodes’ with type ‘const char * const[]’
  783 | extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolcodes[];
      |                                                        ^~~~~~~~~
make[3]: *** [Makefile:230: termcap.o] Error 1

这是我在 CentOS 7 服务器上遇到的问题,这个问题我没能解决。后来想出了一个 workaround:建立一个本地的 CentOS 7 虚拟机,在虚拟机上编译并安装 zsh,然后将安装目录上传到服务器即可。

posted @ 2024-10-31 01:43  Undefined443  阅读(50)  评论(0)    收藏  举报