从源码构建tmux | AI生成和翻译

Home 2026.06

以下是完整的构建过程:

问题: tmux 未安装,brew 速度太慢,需要从源码构建。

发现的依赖项:

步骤 1:下载源码压缩包

cd ~/tmp-build
curl -fSL -o libevent-2.1.12-stable.tar.gz \
  https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz
curl -fSL -o tmux-3.7.tar.gz \
  https://github.com/tmux/tmux/releases/download/3.7/tmux-3.7.tar.gz

步骤 2:构建 libevent(约 30 秒)

cd libevent-2.1.12-stable
./configure --prefix=$HOME/.local --disable-shared --disable-openssl
make -j4
make install

步骤 3:构建 tmux(约 20 秒)

cd tmux-3.7
SDK=$(xcrun --show-sdk-path)
CFLAGS="-I$HOME/.local/include -I${SDK}/usr/include" \
LDFLAGS="-L$HOME/.local/lib" \
./configure --prefix=$HOME/.local --disable-utf8proc
make -j4
make install

步骤 4:配置 PATH

echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc

结果:

~/.local/bin/tmux 3.7
~/.local/lib/libevent*.a(静态,无运行时依赖)

为何无需 brew 也能工作:

清理: rm -rf ~/tmp-build——安装后不再需要源码压缩包。


Back Donate