tmux源码编译

从github下载tmux源码

如果下载不了,可以使用浏览器下载到本地再上传至服务器。
  • 所内github被屏蔽了,登不上去。

检查依赖包

  • (base) [chpeng@localhost tmp]$ rpm -qa | grep libevent
  • libevent-2.0.21-4.el7.x86_64
  • (base) [chpeng@localhost tmp]$ rpm -qa | grep ncurses
  • ncurses-base-5.9-14.20130511.el7_4.noarch
  • ncurses-libs-5.9-14.20130511.el7_4.x86_64
  • ncurses-5.9-14.20130511.el7_4.x86_64
  • ncurses-devel-5.9-14.20130511.el7_4.x86_64
查询结果显示依赖包libevent, ncurses已有,但是缺少libevent-devel

源码编译libevent

  • (base) [chpeng@localhost tmp]$ tar -xf libevent-release-2.1.12-stable.tar.gz 
  • (base) [chpeng@localhost tmp]$ cd libevent-release-2.1.12-stable/
  • (base) [chpeng@localhost libevent-release-2.1.12-stable]$ sh autogen.sh 
  • autoreconf: Entering directory `.'
  • autoreconf: configure.ac: not using Gettext
  • autoreconf: running: aclocal --force -I m4
  • autoreconf: configure.ac: tracing
  • autoreconf: configure.ac: creating directory build-aux
  • autoreconf: running: libtoolize --copy --force
  • libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, 'build-aux'.
  • libtoolize: copying file 'build-aux/ltmain.sh'
  • libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
  • libtoolize: copying file 'm4/libtool.m4'
  • libtoolize: copying file 'm4/ltoptions.m4'
  • libtoolize: copying file 'm4/ltsugar.m4'
  • libtoolize: copying file 'm4/ltversion.m4'
  • libtoolize: copying file 'm4/lt~obsolete.m4'
  • autoreconf: running: /usr/bin/autoconf --force
  • autoreconf: running: /usr/bin/autoheader --force
  • autoreconf: running: automake --add-missing --copy --force-missing
  • configure.ac:39: installing 'build-aux/compile'
  • configure.ac:26: installing 'build-aux/config.guess'
  • configure.ac:26: installing 'build-aux/config.sub'
  • configure.ac:14: installing 'build-aux/install-sh'
  • configure.ac:14: installing 'build-aux/missing'
  • Makefile.am: installing 'build-aux/depcomp'
  • parallel-tests: installing 'build-aux/test-driver'
  • autoreconf: Leaving directory `.'
  • (base) [chpeng@localhost libevent-release-2.1.12-stable]$ ./configure --prefix=/home/chpeng/.local/libevent-2.1.12
  • (base) [chpeng@localhost libevent-release-2.1.12-stable]$ make -j 10
  • (base) [chpeng@localhost libevent-release-2.1.12-stable]$ make install
libevent-devel安装到了/home/chpeng/.local/libevent-2.1.12中
为了编译时使用libevent-devel的header files, shared libraries,需要在进行编译的终端下使用下面的命令设置环境变量
  • (base) [chpeng@localhost libevent-2.1.12]$ export C_INCLUDE_PATH=/home/chpeng/.local/libevent-2.1.12/include:$C_INCLUDE_PATH
  • (base) [chpeng@localhost libevent-2.1.12]$ export CPLUS_INCLUDE_PATH=/home/chpeng/.local/libevent-2.1.12/include:$CPLUS_INCLUDE_PATH
  • (base) [chpeng@localhost libevent-release-2.1.12-stable]$ export LIBRARY_PATH=/home/chpeng/.local/libevent-2.1.12/lib:$LIBRARY_PATH

编译

  • (base) [chpeng@localhost tmp]$ tar -xf tmux-3.2a.tar.gz 
  • (base) [chpeng@localhost tmp]$ cd tmux-3.2a/
  • (base) [chpeng@localhost tmux-3.2a]$ sh autogen.sh 
  • configure.ac:46: installing 'etc/compile'
  • configure.ac:10: installing 'etc/config.guess'
  • configure.ac:10: installing 'etc/config.sub'
  • configure.ac:8: installing 'etc/install-sh'
  • configure.ac:8: installing 'etc/missing'
  • Makefile.am: installing 'etc/depcomp'
  • configure.ac: installing 'etc/ylwrap'
  • (base) [chpeng@localhost tmux-3.2a]$ ./configure --prefix=/home/chpeng/.local/tmux-3.2a
  • (base) [chpeng@localhost tmux-3.2a]$ make -j 10
  • (base) [chpeng@localhost tmux-3.2a]$ make install
tmux安装到了/home/chpeng/.local/tmux-3.2a中

使用

libevent-devel是自编译的,需要将Lib目录加入LD_LIBRARY_PATH中,tmux才能正常使用,将export LD_LIBRARY_PATH=/home/chpeng/.local/libevent-2.1.12/lib:$LD_LIBRARY_PATH加入~/.bashrc中。
使用~/.local/tmux-3.2a/bin/tmux就可使用tmux了。或者为了方便,可以将其加入PATH中。