编译 tmux

Undefined443 / 2024-10-29 / 原文

编译 tmux

  1. 下载源码:

    前往 tmux/tmux 下载源码包。

  2. 解压并安装:

    ./configure --prefix="$HOME/.local"
    make -j$(nproc)
    make install
    

编译依赖项

在配置 tmux 时可能会因缺少依赖项而编译失败。此时需要先编译依赖项。

ncurses

  1. 下载源码:

    前往 GNU FTP 服务器下载 ncurses 源码包。

  2. 解压并安装:

    ./configure --prefix=$HOME/.local --with-shared --with-termlib --enable-pc-files --with-pkg-config-libdir=$HOME/.local/lib/pkgconfig --enable-overwrite
    make -j$(nproc)
    make install
    

    设置环境变量:

    export PKG_CONFIG_PATH="$HOME/.local/lib/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}}"
    

libevent

  1. 前往 libevent/libevent 下载源码包。

  2. 解压并安装:

    ./configure --prefix="$HOME/.local" --enable-shared
    make -j$(nproc)
    make install
    

参考:Building dependencies

Troubleshooting

无法编译 ncurses

在编译 ncurses 时出现如下报错:

/usr/bin/ld: /home/user/.local/lib/libncursesw.a(tty_update.o): relocation R_X86_64_32 against symbol `_nc_outch_sp' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/user/.local/lib/libncursesw.a(lib_vid_attr.o): relocation R_X86_64_32 against symbol `_nc_outc_wrapper' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/user/.local/lib/libncursesw.a(lib_wacs.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/user/.local/lib/libncursesw.a(lib_acs.o): relocation R_X86_64_32S against symbol `acs_map' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/user/.local/lib/libncursesw.a(lib_cur_term.o): relocation R_X86_64_32 against symbol `ttytype' can not be used when making a shared object; recompile with -fPIC
...

解决方法:

rm -rf /home/user/.local/lib/libncurses*
rm -rf /home/user/.local/include/ncursew

然后再次尝试编译。