如果不想影響全局,可以直接把包或者軟件安裝在自己的根目錄。
- 源碼的下載
wget https://github.com/tmux/tmux/releases/download/2.8/tmux-2.8.tar.gz # 這裏以tmux2.8版本爲例
wget https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz
wget http://ftp.gnu.org/gnu/ncurses/ncurses-6.0.tar.gz
- 安裝Tmux依賴:libevent以及ncurses
# 安裝libevent
cd libevent-2.0.22-stable
./configure --prefix=$HOME/.local --disable-shared
make
make install
#安裝ncurses
cd ncurses-6.0
./configure --prefix=$HOME/.local
make
make install
- 其中,在安裝ncurses使用make命令的時候可能會報以下錯誤:
In file included from ../ncurses/curses.priv.h:283:0,
from ../ncurses/lib_gen.c:19:
_46863.c:835:15: error: expected ‘)’ before ‘int’
../include/curses.h:1594:56: note: in definition of macro ‘mouse_trafo’
#define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen) ^
Makefile:790: recipe for target '../objects/lib_gen.o' failed
make[1]: *** [../objects/lib_gen.o] Error 1
–>解決辦法:
cd ncurses-6.0/include
vim curses.tail
大約是在104行,去除104行後面的註釋。即:刪除/* generated */
103 extern NCURSES_EXPORT(bool) wmouse_trafo (const WINDOW*, int*, int*, bool);
104 extern NCURSES_EXPORT(bool) mouse_trafo (int*, int*, bool); /* generated */
然後使用命令:make clean
,再重新使用命令make
balabala
- 安裝tmux
#tmux
cd tmux-2.8
./configure CFLAGS="-I$HOME/.local/include -I$HOME/.local/include/ncurses" LDFLAGS="-L$HOME/.local/lib -L$HOME/.local/include/ncurses -L$HOME/.local/include" CPPFLAGS="-I$HOME/.local/include -I$HOME/.local/include/ncurses" LDFLAGS="-static -L$HOME/.local/include -L$HOME/.local/include/ncurses -L$HOME/.local/lib"
make
cp tmux $HOME/.local/bin
- 添加環境變量
#將下面的語句添加到.bashrc中
export PATH="$HOME/.local/bin:$PATH"
#重載環境
source ~/.bashrc