Linux 非 root 用户安装 ncurses

ncurses 是一个提供文本终端处理功能的库, 用于创建基于文本的用户界面。本章节展示了如何从源码编译和安装 ncurses-5.6

通过这种方式, 可以将 ncurses 库安装到用户主目录的指定位置, 并在编译其他软件时引用该目录, 从而避免与系统默认安装的 ncurses 冲突。同时也便于管理多个版本的 ncurses

下载与解压源码

wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.6.tar.gz
tar zxf ncurses-5.6.tar.gz

配置、编译与安装

./configure -prefix=$HOME/screen -with-shared -without-debug  --enable-widec
make && make install

解释各个参数的含义

--prefix=$HOME/screen   指定安装目录为 $HOME/screen, 表示将 ncurses 安装到用户主目录下的 screen 文件夹中
--with-shared           编译动态链接的共享库
--without-debug         不包含调试信息, 以减小库的大小
--enable-widec          启用对宽字符(如 Unicode)的支持

执行 make 命令进行编译, 并通过 make install 安装到指定目录 $HOME/screen

编译其他软件时使用自定义的 ncurses

在编译安装其他依赖 ncurses 的软件时, 可能需要指定自定义 ncurses 的路径。可以通过以下配置命令实现

./configure --prefix=$HOME CFLAGS="-I$HOME/include -I$HOME/include/ncursesw" LDFLAGS="-L$HOME/lib -L$HOME/include/ncursesw -L$HOME/include" CPPFLAGS="-I$HOME/include -I$HOME/include/ncursesw" LDFLAGS="-static -L$HOME/include -L$HOME/include/ncursesw -L$HOME/lib"

原文

记录23–编译安装ncurses-5.6
非root用户源码安装Tmux

最后更新于 2018-03-29
使用 Hugo 构建
主题 StackJimmy 设计