vim: error while loading shared libraries

在CentOS操作系统中安装完vim,在使用它编辑文件的时候出现了如下报错

-bash-3.2# vim file.txt
vim: error while loading shared libraries: libgpm.so.1: cannot open shared object file: No such file or directory


追踪一下vim命令都使用了哪些链接库

-bash-3.2# ldd /usr/bin/vim
libncurses.so.5 => /usr/lib64/libncurses.so.5 (0x00002b53b4b8c000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x00002b53b4de9000)
libacl.so.1 => /lib64/libacl.so.1 (0x00002b53b5001000)
libgpm.so.1 => not found
libperl.so => /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libperl.so (0x00002b53b5208000)
libresolv.so.2 => /lib64/libresolv.so.2 (0x00002b53b553e000)
libutil.so.1 => /lib64/libutil.so.1 (0x00002b53b5754000)
libc.so.6 => /lib64/libc.so.6 (0x00002b53b5957000)
libm.so.6 => /lib64/libm.so.6 (0x00002b53b5caf000)
libdl.so.2 => /lib64/libdl.so.2 (0x00002b53b5f33000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00002b53b6137000)
libsepol.so.1 => /lib64/libsepol.so.1 (0x00002b53b6352000)
/lib64/ld-linux-x86-64.so.2 (0x00002b53b496e000)
libattr.so.1 => /lib64/libattr.so.1 (0x00002b53b6599000)
libnsl.so.1 => /lib64/libnsl.so.1 (0x00002b53b679d000)
libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00002b53b69b5000)

查看一下 gpm是否已经安装

-bash-3.2# rpm -ql gpm|grep libgpm.so

-bash-3.2# rpm -ivh gpm-1.20.1-74.1.x86_64.rpm
-bash-3.2# rpm -ivh gpm-devel-1.20.1-74.1.x86_64.rpm


配置好yum以后,直接yum安装gpm和gpm-devel包

ash-3.2# yum install gpm gpm-devel -y

之后再查询是否已经安装成功

[BaihuiMail~]#rpm -ql gpm|grep libgpm.so
/usr/lib64/libgpm.so.1
/usr/lib64/libgpm.so.1.19.0


然后将库文件做符号链接

[BaihuiMail~]#ln -s /usr/lib64/libgpm.so.1 /lib/libgpm.so.1


再次追踪vim

[BaihuiMail~]#ldd /usr/bin/vim
libncurses.so.5 => /usr/lib64/libncurses.so.5 (0x00002aad2e79e000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x00002aad2e9fb000)
libacl.so.1 => /lib64/libacl.so.1 (0x00002aad2ec13000)
libgpm.so.1 => /usr/lib64/libgpm.so.1 (0x00002aad2ee1a000)
libperl.so => /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libperl.so (0x00002aad2f020000)
libresolv.so.2 => /lib64/libresolv.so.2 (0x00002aad2f356000)
libutil.so.1 => /lib64/libutil.so.1 (0x00002aad2f56c000)
libc.so.6 => /lib64/libc.so.6 (0x00002aad2f76f000)
libm.so.6 => /lib64/libm.so.6 (0x00002aad2fac7000)
libdl.so.2 => /lib64/libdl.so.2 (0x00002aad2fd4b000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00002aad2ff4f000)
libsepol.so.1 => /lib64/libsepol.so.1 (0x00002aad3016a000)
/lib64/ld-linux-x86-64.so.2 (0x00002aad2e580000)
libattr.so.1 => /lib64/libattr.so.1 (0x00002aad303b1000)
libnsl.so.1 => /lib64/libnsl.so.1 (0x00002aad305b5000)
libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00002aad307cd000)

另外为了方面使用vi命令,需要在系统中添加别名,要不然没办法使用vi编辑文件

编辑环境变量

将  alias vi='vim' 加入文件 /etc/profile

为了使别名立即生效,需要使用命令: source  /etc/profile


这样不管是vi还是vim都可以正常使用了



你可能感兴趣的:(linux)