编译 tmux

编译 tmux

  1. 下载 tmux 源码:

    wget https://github.com/tmux/tmux/releases/download/3.5a/tmux-3.5a.tar.gz
    tar -zxf tmux-*.tar.gz && rm tmux-*.tar.gz
    cd tmux-*
    
  2. 编译并安装:

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

编译依赖项

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

ncurses

  1. 下载源码:

    前往 ftp.gnu.org 下载 ncurses 源码包。

    wget https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.5.tar.gz
    tar -xzf ncurses-*.tar.gz && rm ncurses-*.tar.gz
    cd ncurses-*
    
  2. 编译并安装:

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

    设置环境变量:

    export PKG_CONFIG_PATH="$HOME/.local/lib/pkgconfig"
    

openssl

  1. openssl/openssl 下载最新源码包:

    wget https://github.com/openssl/openssl/releases/download/openssl-3.4.1/openssl-3.4.1.tar.gz
    tar -zxf openssl-*.tar.gz && rm openssl-*.tar.gz
    cd openssl-*
    
  2. 编译并安装:

    mkdir build && cd build
    ../Configure --prefix="$HOME/.local"
    make -j$(nproc)
    make install
    
  3. 设置环境变量:

    export PKG_CONFIG_PATH="$HOME/.local/lib64/pkgconfig:$PKG_CONFIG_PATH"
    

libevent

libevent 依赖 openssl

  1. 检查 openssl 存在:

    pkg-config --libs openssl
    
  2. 前往 libevent/libevent 下载源码包:

    wget https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz
    tar -zxf libevent-*.tar.gz && rm libevent-*.tar.gz
    cd libevent-*
    
  3. 编译并安装:

    mkdir build && cd build
    ../configure --enable-shared --prefix="$HOME/.local"
    make -j$(nproc)
    make install
    
  4. 设置环境变量:

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

参考:Building dependencies | tmux Wiki

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

然后再次尝试编译。

Can't locate IPC/Cmd.pm in @INC

$ ../Configure --prefix="/data/.local"
Can't locate IPC/Cmd.pm in @INC (@INC contains: /home/centos/.local/src/openssl-3.4.1/util/perl /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 . /home/centos/.local/src/openssl-3.4.1/external/perl/Text-Template-1.56/lib) at /home/centos/.local/src/openssl-3.4.1/util/perl/OpenSSL/config.pm line 19.
BEGIN failed--compilation aborted at /home/centos/.local/src/openssl-3.4.1/util/perl/OpenSSL/config.pm line 19.
Compilation failed in require at ../Configure line 23.
BEGIN failed--compilation aborted at ../Configure line 23.

解决方法:

  • 如果有 sudo 权限:

    sudo yum install perl-IPC-Cmd  # 安装 IPC/Cmd.pm
    
  • 如果没有 sudo 权限,你需要编译安装 Perl 并安装相应的 Perl 包。参见移植 Perl 包

posted @ 2024-10-20 13:39  Undefined443  阅读(57)  评论(0)    收藏  举报