在CentOS 6安装最新稳定版tmux

2017-05-26|Categories: Linux|

CentOS 6可以通过yum install tmux安装tmux,但这样安装的tmux版本是老旧的1.8。想要安装最新稳定版的tmux必须从源代码编译。

编译过程其实很简单,关键是提前安装好依赖包,尤其是libevent2-devel,完整步骤如下:

yum安装libevent2-devel(推荐)

yum -y install ncurses-devel libevent2-devel

wget https://github.com/tmux/tmux/releases/download/2.5/tmux-2.5.tar.gz
tar -xf tmux-2.5.tar.gz
cd tmux-2.5
./configure
make && make install

从官方网站安装最新版libevent2-devel

以下代码和解释来自 https://superuser.com/a/738830/579057

yum -y install ncurses-devel

wget https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz
tar -xf libevent-2.1.8-stable.tar.gz
cd libevent-2.1.8-stable
./configure
# use `-j` to specify how many cpu cores to use when compiling,
# without specifying the `make` will use just one core
make -j 2
make install
cd ..

wget https://github.com/tmux/tmux/releases/download/2.5/tmux-2.5.tar.gz
tar -xf tmux-2.5.tar.gz
cd tmux-2.5
./configure LDFLAGS="-Wl,-rpath,/usr/local/lib"
make -j 2
make install

There are three blocks of commands here:

  1. The yum command installs the ncurses-devel package (if it is not already present) required to compile tmux.
  2. Then we compile libevent version 2.1 from source and install it.
  3. Then we compile tmux version 2.5 from source and install it. While doing so, we ensure that we link tmux to libevent that we installed in /usr/local/lib, otherwise would get this error: tmux: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory.

作者说的非常清楚:从官网安装libevent之后,在编译tmux时必须指定libevent的安装路径,否则tmux会报错,说「载入共享库文件错误」。

Leave A Comment