虚拟机的linux系统如何安装curses函数库

Ubuntu下安装方法

方法一:

1.sudo apt-get update
2.sudo apt-get upgrade
3.sudo apt-get install libncurses5-dev libncursesw5-dev

直接执行步骤2,会显示如下的错误:

Err http://us.archive.ubuntu.com/ubuntu/ saucy/main libtinfo-dev i386 5.9+20130608-1ubuntu1
  404  Not Found [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com/ubuntu/ saucy/main libncurses5-dev i386 5.9+20130608-1ubuntu1
  404  Not Found [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com/ubuntu/ saucy/main libncursesw5-dev i386 5.9+20130608-1ubuntu1
  404  Not Found [IP: 91.189.91.13 80]
Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/n/ncurses/libtinfo-dev_5.9+20130608-1ubuntu1_i386.deb  404  Not Found [IP: 91.189.91.13 80]
Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/n/ncurses/libncurses5-dev_5.9+20130608-1ubuntu1_i386.deb  404  Not Found [IP: 91.189.91.13 80]
Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/n/ncurses/libncursesw5-dev_5.9+20130608-1ubuntu1_i386.deb  404  Not Found [IP: 91.189.91.13 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

上面的问题应该是说无法连接网站,我是虚拟机上的ubuntu,不知道直接安装ubuntu会不会出现上述问题。我尝试了各种方法,以为是linux无法上网,但是我ping win7主机,可以ping通。我直接输入上面的网址也进不去。

要是执行步骤1也会出现问题,如下:

Err http://security.ubuntu.com saucy-security/main Sources
  404  Not Found [IP: 91.189.92.200 80]
Err http://security.ubuntu.com saucy-security/restricted Sources
  404  Not Found [IP: 91.189.92.200 80]
Err http://security.ubuntu.com saucy-security/universe Sources
  404  Not Found [IP: 91.189.92.200 80]
Err http://security.ubuntu.com saucy-security/multiverse Sources
  404  Not Found [IP: 91.189.92.200 80]
Err http://security.ubuntu.com saucy-security/main i386 Packages
  404  Not Found [IP: 91.189.92.200 80]
Err http://security.ubuntu.com saucy-security/restricted i386 Packages
  404  Not Found [IP: 91.189.92.200 80]
Err http://security.ubuntu.com saucy-security/universe i386 Packages
  404  Not Found [IP: 91.189.92.200 80]
Err http://security.ubuntu.com saucy-security/multiverse i386 Packages
  404  Not Found [IP: 91.189.92.200 80]
Ign http://us.archive.ubuntu.com saucy/main Translation-en_US
Ign http://us.archive.ubuntu.com saucy/main Translation-en
Ign http://us.archive.ubuntu.com saucy/multiverse Translation-en_US
Ign http://us.archive.ubuntu.com saucy/multiverse Translation-en
Ign http://us.archive.ubuntu.com saucy/restricted Translation-en_US
Ign http://us.archive.ubuntu.com saucy/restricted Translation-en
Ign http://us.archive.ubuntu.com saucy/universe Translation-en_US
Ign http://us.archive.ubuntu.com saucy/universe Translation-en
Ign http://us.archive.ubuntu.com saucy-updates/main Translation-en_US
Ign http://us.archive.ubuntu.com saucy-updates/main Translation-en
Ign http://us.archive.ubuntu.com saucy-updates/multiverse Translation-en_US
Ign http://us.archive.ubuntu.com saucy-updates/multiverse Translation-en
Ign http://us.archive.ubuntu.com saucy-updates/restricted Translation-en_US
Ign http://us.archive.ubuntu.com saucy-updates/restricted Translation-en
Ign http://us.archive.ubuntu.com saucy-updates/universe Translation-en_US
Ign http://us.archive.ubuntu.com saucy-updates/universe Translation-en
Ign http://us.archive.ubuntu.com saucy-backports/main Translation-en_US
Ign http://us.archive.ubuntu.com saucy-backports/main Translation-en
Ign http://us.archive.ubuntu.com saucy-backports/multiverse Translation-en_US
Ign http://us.archive.ubuntu.com saucy-backports/multiverse Translation-en
Ign http://us.archive.ubuntu.com saucy-backports/restricted Translation-en_US
Ign http://us.archive.ubuntu.com saucy-backports/restricted Translation-en
Ign http://us.archive.ubuntu.com saucy-backports/universe Translation-en_US
Ign http://us.archive.ubuntu.com saucy-backports/universe Translation-en
Err http://us.archive.ubuntu.com saucy/main Sources
  404  Not Found [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com saucy/restricted Sources
  404  Not Found [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com saucy/universe Sources
  404  Not Found [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com saucy/multiverse Sources
  404  Not Found [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com saucy/main i386 Packages
  404  Not Found [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com saucy/restricted i386 Packages
  404  Not Found [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com saucy/universe i386 Packages
  404  Not Found [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com saucy/multiverse i386 Packages
  404  Not Found [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com saucy-updates/main Sources
  404  Not Found [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com saucy-updates/restricted Sources
  404  Not Found [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com saucy-updates/universe Sources
  404  Not Found [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com saucy-updates/multiverse Sources
  404  Not Found [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com saucy-updates/main i386 Packages
  404  Not Found [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com saucy-updates/restricted i386 Packages
  404  Not Found [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com saucy-updates/universe i386 Packages
  404  Not Found [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com saucy-updates/multiverse i386 Packages
  404  Not Found [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com saucy-backports/main Sources
  404  Not Found [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com saucy-backports/restricted Sources
  404  Not Found [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com saucy-backports/universe Sources
  404  Not Found [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com saucy-backports/multiverse Sources
  404  Not Found [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com saucy-backports/main i386 Packages
  404  Not Found [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com saucy-backports/restricted i386 Packages
  404  Not Found [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com saucy-backports/universe i386 Packages
  404  Not Found [IP: 91.189.91.13 80]
Err http://us.archive.ubuntu.com saucy-backports/multiverse i386 Packages
  404  Not Found [IP: 91.189.91.13 80]
Fetched 711 kB in 2min 13s (5,328 B/s)
W: Failed to fetch bzip2:/var/lib/apt/lists/partial/extras.ubuntu.com_ubuntu_dists_saucy_main_binary-i386_Packages  Hash Sum mismatch


W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/saucy/main/source/Sources  404  Not Found [IP: 91.189.91.13 80]


W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/saucy/restricted/source/Sources  404  Not Found [IP: 91.189.91.13 80]


W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/saucy/universe/source/Sources  404  Not Found [IP: 91.189.91.13 80]


W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/saucy/multiverse/source/Sources  404  Not Found [IP: 91.189.91.13 80]


W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/saucy/main/binary-i386/Packages  404  Not Found [IP: 91.189.91.13 80]


W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/saucy-security/main/source/Sources  404  Not Found [IP: 91.189.92.200 80]


W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/saucy/restricted/binary-i386/Packages  404  Not Found [IP: 91.189.91.13 80]


W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/saucy-security/restricted/source/Sources  404  Not Found [IP: 91.189.92.200 80]


W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/saucy/universe/binary-i386/Packages  404  Not Found [IP: 91.189.91.13 80]


W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/saucy-security/universe/source/Sources  404  Not Found [IP: 91.189.92.200 80]


W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/saucy/multiverse/binary-i386/Packages  404  Not Found [IP: 91.189.91.13 80]


W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/saucy-security/multiverse/source/Sources  404  Not Found [IP: 91.189.92.200 80]


W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/saucy-security/main/binary-i386/Packages  404  Not Found [IP: 91.189.92.200 80]


W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/saucy-security/restricted/binary-i386/Packages  404  Not Found [IP: 91.189.92.200 80]


W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/saucy-security/universe/binary-i386/Packages  404  Not Found [IP: 91.189.92.200 80]


W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/saucy-security/multiverse/binary-i386/Packages  404  Not Found [IP: 91.189.92.200 80]


W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/saucy-updates/main/source/Sources  404  Not Found [IP: 91.189.91.13 80]


W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/saucy-updates/restricted/source/Sources  404  Not Found [IP: 91.189.91.13 80]


W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/saucy-updates/universe/source/Sources  404  Not Found [IP: 91.189.91.13 80]


W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/saucy-updates/multiverse/source/Sources  404  Not Found [IP: 91.189.91.13 80]


W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/saucy-updates/main/binary-i386/Packages  404  Not Found [IP: 91.189.91.13 80]


W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/saucy-updates/restricted/binary-i386/Packages  404  Not Found [IP: 91.189.91.13 80]


W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/saucy-updates/universe/binary-i386/Packages  404  Not Found [IP: 91.189.91.13 80]


W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/saucy-updates/multiverse/binary-i386/Packages  404  Not Found [IP: 91.189.91.13 80]


W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/saucy-backports/main/source/Sources  404  Not Found [IP: 91.189.91.13 80]


W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/saucy-backports/restricted/source/Sources  404  Not Found [IP: 91.189.91.13 80]


W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/saucy-backports/universe/source/Sources  404  Not Found [IP: 91.189.91.13 80]


W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/saucy-backports/multiverse/source/Sources  404  Not Found [IP: 91.189.91.13 80]


W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/saucy-backports/main/binary-i386/Packages  404  Not Found [IP: 91.189.91.13 80]


W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/saucy-backports/restricted/binary-i386/Packages  404  Not Found [IP: 91.189.91.13 80]


W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/saucy-backports/universe/binary-i386/Packages  404  Not Found [IP: 91.189.91.13 80]


W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/saucy-backports/multiverse/binary-i386/Packages  404  Not Found [IP: 91.189.91.13 80]


E: Some index files failed to download. They have been ignored, or old ones used instead.


这个问题一直困扰着我,我无法解决它。有时候下载其他的函数库的时候也会出现类似的情况,请大神赐教,这是怎么回事啊?尝试了很多方法都不能解决。

最后实在无奈只能换另外一种方法安装curses。


方法二:

下载ncurses<version>.tar.gz压缩文件

下载地址:http://ftp.gnu.org/pub/gnu/ncurses/

可以选择不同的版本,这里以ncurses-5.9.tar.gz为准

压缩文件放在一个路径下,进行解压:

tar xvf ncurses-5.9.tar.gz

解压完成后进行安装,这时候需要root权限。进入root.

sudo su root   输入password

然后进入解压的目录,我的路径如下:

cd /home/chende/Documents/ncurses5.9/

./configure 按照你的系统环境制作安装配置文件

make 编译源代码并且编译ncurese库

这一步check文件的完整性,并进行编译

最后

make install安装编译好的NCURSES库

检查curses库是否安装成功:

进入/usr/lib下查找是否有libncurses.so或libncurses.a这个库

或者写程序进行检测

#include<stdio.h>
#include<curses.h>
main(){
initscr();
clear();
move(10,10);
addstr("my first screen display");
move(20,20);
refresh();
getch();
endwin();
}

直接gcc myhello.cpp 会出现以下问题:

/tmp/ccvO5sn3.o: In function `main':
myhello.cpp:(.text+0xa): undefined reference to `initscr'
myhello.cpp:(.text+0xf): undefined reference to `clear'
myhello.cpp:(.text+0x23): undefined reference to `move'
myhello.cpp:(.text+0x28): undefined reference to `stdscr'
myhello.cpp:(.text+0x40): undefined reference to `waddnstr'
myhello.cpp:(.text+0x54): undefined reference to `move'
myhello.cpp:(.text+0x59): undefined reference to `refresh'
myhello.cpp:(.text+0x5e): undefined reference to `stdscr'
myhello.cpp:(.text+0x66): undefined reference to `wgetch'
myhello.cpp:(.text+0x6b): undefined reference to `endwin'
collect2: error: ld returned 1 exit status

在终端中输入下面的指令可以编译成功

gcc myhello.cpp -l curses -o myhello

输入下面指令显示:
./myhello

至此curses函数库安装成功,并且可以成功调用。




你可能感兴趣的:(linux,虚拟机,gcc,gnu)