在Debian和Ubuntu系统上利用apt-file查询缺失软件包
来源:互联网 发布:简单java代码 编辑:程序博客网 时间:2024/06/05 18:45
在Debian和Ubuntu系统上利用apt-file查询缺失软件包2007-03-02 18:59:35
分类: LINUX
在Debian和Ubuntu系统上利用apt-file查询缺失软件包
作者:Falko Timme <ft [at] falkotimme [dot] com>
本文主要描述了如何在Debian和Ubuntu系统上利用apt-file查询缺失的软件包。apt-file允许你查询一个文件名,该命令会返回包含该文件的可以安装的软件包的名字。
本文中阐述的方法我不保证对你有效。
1、初始情况
我想大家都可能有过这样的经历:从源代码编译软件包时,编译过程会因为某个你从没听过的文件的缺失而致使编译过程终止:
root@falko-desktop:~/avant-window-navigator-0.1.1# make
make all-recursive
make[1]: Entering directory `/root/avant-window-navigator-0.1.1'
Making all in src
make[2]: Entering directory `/root/avant-window-navigator-0.1.1/src'
if gcc -DHAVE_CONFIG_H -I. -I. -I.. -DORBIT2=1 -pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/libwnck-1.0 -I/usr/include/gconf/2 -I/usr/include/orbit-2.0 -DDATADIR=\""/usr/local/share"\" -DGNOMELOCALEDIR=\""/usr/local/share/locale"\" -g -O2 -Wall -pedantic -std=c99 -fno-strict-aliasing -fmessage-length=0 -D_FORTIFY_SOURCE=2 -MT main.o -MD -MP -MF ".deps/main.Tpo" -c -o main.o main.c; \
then mv -f ".deps/main.Tpo" ".deps/main.Po"; else rm -f ".deps/main.Tpo"; exit 1; fi
main.c:21:21: error: gtk/gtk.h: No such file or directory
In file included from main.c:25:
awn-gconf.h:69: error: expected â)â before â*â token
In file included from main.c:26:
awn-bar.h:43: error: expected specifier-qualifier-list before âGtkWindowâ
awn-bar.h:45: warning: struct has no members
awn-bar.h:48: error: expected specifier-qualifier-list before âGtkWindowClassâ
awn-bar.h:49: warning: struct has no members
awn-bar.h:51: error: expected â=â, â,â, â;â, âasmâ or â%3POST http://control.cublog.cn/article_insert.php 6#226; token
awn-bar.h:55: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before â*â token
awn-bar.h:57: error: expected â)â before â*â token
awn-bar.h:58: error: expected â)â before â*â token
In file included from main.c:27:
awn-window.h:43: error: expected specifier-qualifier-list before âGtkWindowâ
awn-window.h:45: warning: struct has no members
awn-window.h:48: error: expected specifier-qualifier-list before âGtkWindowClassâ
awn-window.h:49: warning: struct has no members
awn-window.h:55: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before â*â token
In file included from main.c:28:
awn-app.h:30:29: error: libwnck/libwnck.h: No such file or directory
In file included from main.c:28:
awn-app.h:60: error: expected specifier-qualifier-list before âWnckWindowâ
awn-app.h:80: warning: struct has no members
awn-app.h:83: error: expected â)â before â*â token
In file included from main.c:29:
awn-win-manager.h:35: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before â*â token
main.c:32: error: expected â)â before â*â token
main.c: In function âmainâ:
main.c:48: error: âGtkWidgetâ undeclared (first use in this function)
main.c:48: error: (Each undeclared identifier is reported only once
main.c:48: error: for each function it appears in.)
main.c:48: error: âwinâ undeclared (first use in this function)
main.c:49: error: âbarâ undeclared (first use in this function)
main.c:50: error: âboxâ undeclared (first use in this function)
main.c:51: error: âwinmanâ undeclared (first use in this function)
main.c:52: error: âlabâ undeclared (first use in this function)
main.c:54: warning: implicit declaration of function âgtk_initâ
main.c:56: warning: implicit declaration of function âawn_bar_newâ
main.c:58: warning: implicit declaration of function âawn_window_newâ
main.c:59: warning: implicit declaration of function âgtk_window_set_policyâ
main.c:59: warning: implicit declaration of function âGTK_WINDOWâ
main.c:61: error: âexposeâ undeclared (first use in this function)
main.c:64: warning: implicit declaration of function âgtk_hbox_newâ
main.c:66: warning: implicit declaration of function âawn_win_mgr_newâ
main.c:68: warning: implicit declaration of function âgtk_box_pack_startâ
main.c:68: warning: implicit declaration of function âGTK_BOXâ
main.c:68: warning: implicit declaration of function âgtk_label_newâ
main.c:72: warning: implicit declaration of function âgtk_container_addâ
main.c:72: warning: implicit declaration of function âGTK_CONTAINERâ
main.c:74: warning: implicit declaration of function âgtk_widget_show_allâ
main.c:76: warning: implicit declaration of function âgtk_window_set_transient_forâ
main.c:79: warning: implicit declaration of function âgtk_mainâ
make[2]: *** [main.o] Error 1
make[2]: Leaving directory `/root/avant-window-navigator-0.1.1/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/avant-window-navigator-0.1.1'
make: *** [all] Error 2
root@falko-desktop:~/avant-window-navigator-0.1.1#
那么你该如何知道是哪个软件包包含了该缺失文件呢?安装了该软件包后再重新进行编译。对于基于Debian的系统(例如Ubuntu)来说,就可以使用apt-file,apt-file通过查询文件来获得包含该文件的软件包。
2、安装apt-file
安装apt-file:
3、查询包
好,现在让我们来搜寻包含文件gtk/gtk.h的软件包。搜寻方式如下:
root@falko-desktop:~/avant-window-navigator-0.1.1# apt-file search gtk/gtk.h
libgfcui-dev: usr/include/gfc-2.0/gfc/gtk/gtk.hh
libgtk+2.0-directfb-dev: usr/include/directfb/gtk-2.0/gtk/gtk.h
libgtk1.2-dev: usr/include/gtk-1.2/gtk/gtk.h
libgtk2.0-dev: usr/include/gtk-2.0/gtk/gtk.h
libgtk2.0-doc: usr/share/doc/libgtk2.0-doc/gtk/gtk.html
root@falko-desktop:~/avant-window-navigator-0.1.1#
你可以看到有三个软件包包含gtk/gtk.h(一个包含gtk/gtk.hh,另一个包含gtk/gtk.html,这两个软件包都不是我们想要的),现在由我们决定该安装哪个软件包。如果你不确定,你可以安装所有三个软件包,或者一个一个安装,并且每安装一个就测试一下编译错误是否还会出现。在本例中,正确的软件包是libgtk2.0-dev,因此我们安装该软件包:
root@falko-desktop:~/avant-window-navigator-0.1.1# make
make all-recursive
make[1]: Entering directory `/root/avant-window-navigator-0.1.1'
Making all in src
make[2]: Entering directory `/root/avant-window-navigator-0.1.1/src'
if gcc -DHAVE_CONFIG_H -I. -I. -I.. -DORBIT2=1 -pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/libwnck-1.0 -I/usr/include/gconf/2 -I/usr/include/orbit-2.0 -DDATADIR=\""/usr/local/share"\" -DGNOMELOCALEDIR=\""/usr/local/share/locale"\" -g -O2 -Wall -pedantic -std=c99 -fno-strict-aliasing -fmessage-length=0 -D_FORTIFY_SOURCE=2 -MT main.o -MD -MP -MF ".deps/main.Tpo" -c -o main.o main.c; \
then mv -f ".deps/main.Tpo" ".deps/main.Po"; else rm -f ".deps/main.Tpo"; exit 1; fi
In file included from /usr/include/gtk-2.0/gtk/gtk.h:170,
from main.c:21:
/usr/include/gtk-2.0/gtk/gtktextbuffer.h:52: warning: ISO C restricts enumerator values to range of âintâ
/usr/include/gtk-2.0/gtk/gtktextbuffer.h:53: warning: ISO C restricts enumerator values to range of âintâ
/usr/include/gtk-2.0/gtk/gtktextbuffer.h:55: warning: ISO C restricts enumerator values to range of âintâ
In file included from main.c:28:
awn-app.h:30:29: error: libwnck/libwnck.h: No such file or directory
In file included from main.c:28:
awn-app.h:60: error: expected specifier-qualifier-list before âWnckWindowâ
awn-app.h:80: warning: struct has no members
awn-app.h:83: error: expected â)â before â*â token
main.c: In function âmainâ:
main.c:52: warning: unused variable âlabâ
make[2]: *** [main.o] Error 1
make[2]: Leaving directory `/root/avant-window-navigator-0.1.1/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/avant-window-navigator-0.1.1'
make: *** [all] Error 2
root@falko-desktop:~/avant-window-navigator-0.1.1#
正如你所看到的,最初的错误没有了,但是又有另一个文件缺失,libwnck/libwnck.h,因此我们再来搜索缺失的包:
root@falko-desktop:~/avant-window-navigator-0.1.1# apt-file search libwnck/libwnck.h
libwnck-dev: usr/include/libwnck-1.0/libwnck/libwnck.h
root@falko-desktop:~/avant-window-navigator-0.1.1#
因此我们安装该缺失的软件包:
4、链接
作者:Falko Timme <ft [at] falkotimme [dot] com>
本文主要描述了如何在Debian和Ubuntu系统上利用apt-file查询缺失的软件包。apt-file允许你查询一个文件名,该命令会返回包含该文件的可以安装的软件包的名字。
本文中阐述的方法我不保证对你有效。
1、初始情况
我想大家都可能有过这样的经历:从源代码编译软件包时,编译过程会因为某个你从没听过的文件的缺失而致使编译过程终止:
root@falko-desktop:~/avant-window-navigator-0.1.1# make
make all-recursive
make[1]: Entering directory `/root/avant-window-navigator-0.1.1'
Making all in src
make[2]: Entering directory `/root/avant-window-navigator-0.1.1/src'
if gcc -DHAVE_CONFIG_H -I. -I. -I.. -DORBIT2=1 -pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/libwnck-1.0 -I/usr/include/gconf/2 -I/usr/include/orbit-2.0 -DDATADIR=\""/usr/local/share"\" -DGNOMELOCALEDIR=\""/usr/local/share/locale"\" -g -O2 -Wall -pedantic -std=c99 -fno-strict-aliasing -fmessage-length=0 -D_FORTIFY_SOURCE=2 -MT main.o -MD -MP -MF ".deps/main.Tpo" -c -o main.o main.c; \
then mv -f ".deps/main.Tpo" ".deps/main.Po"; else rm -f ".deps/main.Tpo"; exit 1; fi
main.c:21:21: error: gtk/gtk.h: No such file or directory
In file included from main.c:25:
awn-gconf.h:69: error: expected â)â before â*â token
In file included from main.c:26:
awn-bar.h:43: error: expected specifier-qualifier-list before âGtkWindowâ
awn-bar.h:45: warning: struct has no members
awn-bar.h:48: error: expected specifier-qualifier-list before âGtkWindowClassâ
awn-bar.h:49: warning: struct has no members
awn-bar.h:51: error: expected â=â, â,â, â;â, âasmâ or â%3POST http://control.cublog.cn/article_insert.php 6#226; token
awn-bar.h:55: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before â*â token
awn-bar.h:57: error: expected â)â before â*â token
awn-bar.h:58: error: expected â)â before â*â token
In file included from main.c:27:
awn-window.h:43: error: expected specifier-qualifier-list before âGtkWindowâ
awn-window.h:45: warning: struct has no members
awn-window.h:48: error: expected specifier-qualifier-list before âGtkWindowClassâ
awn-window.h:49: warning: struct has no members
awn-window.h:55: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before â*â token
In file included from main.c:28:
awn-app.h:30:29: error: libwnck/libwnck.h: No such file or directory
In file included from main.c:28:
awn-app.h:60: error: expected specifier-qualifier-list before âWnckWindowâ
awn-app.h:80: warning: struct has no members
awn-app.h:83: error: expected â)â before â*â token
In file included from main.c:29:
awn-win-manager.h:35: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before â*â token
main.c:32: error: expected â)â before â*â token
main.c: In function âmainâ:
main.c:48: error: âGtkWidgetâ undeclared (first use in this function)
main.c:48: error: (Each undeclared identifier is reported only once
main.c:48: error: for each function it appears in.)
main.c:48: error: âwinâ undeclared (first use in this function)
main.c:49: error: âbarâ undeclared (first use in this function)
main.c:50: error: âboxâ undeclared (first use in this function)
main.c:51: error: âwinmanâ undeclared (first use in this function)
main.c:52: error: âlabâ undeclared (first use in this function)
main.c:54: warning: implicit declaration of function âgtk_initâ
main.c:56: warning: implicit declaration of function âawn_bar_newâ
main.c:58: warning: implicit declaration of function âawn_window_newâ
main.c:59: warning: implicit declaration of function âgtk_window_set_policyâ
main.c:59: warning: implicit declaration of function âGTK_WINDOWâ
main.c:61: error: âexposeâ undeclared (first use in this function)
main.c:64: warning: implicit declaration of function âgtk_hbox_newâ
main.c:66: warning: implicit declaration of function âawn_win_mgr_newâ
main.c:68: warning: implicit declaration of function âgtk_box_pack_startâ
main.c:68: warning: implicit declaration of function âGTK_BOXâ
main.c:68: warning: implicit declaration of function âgtk_label_newâ
main.c:72: warning: implicit declaration of function âgtk_container_addâ
main.c:72: warning: implicit declaration of function âGTK_CONTAINERâ
main.c:74: warning: implicit declaration of function âgtk_widget_show_allâ
main.c:76: warning: implicit declaration of function âgtk_window_set_transient_forâ
main.c:79: warning: implicit declaration of function âgtk_mainâ
make[2]: *** [main.o] Error 1
make[2]: Leaving directory `/root/avant-window-navigator-0.1.1/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/avant-window-navigator-0.1.1'
make: *** [all] Error 2
root@falko-desktop:~/avant-window-navigator-0.1.1#
那么你该如何知道是哪个软件包包含了该缺失文件呢?安装了该软件包后再重新进行编译。对于基于Debian的系统(例如Ubuntu)来说,就可以使用apt-file,apt-file通过查询文件来获得包含该文件的软件包。
2、安装apt-file
安装apt-file:
apt-get install apt-file
安装完成后,我们必须通过如下方式更新apt-file的软件包数据库:apt-file update
注意:每次修改了/etc/apt/source.list后,都要更新该软件包数据库。3、查询包
好,现在让我们来搜寻包含文件gtk/gtk.h的软件包。搜寻方式如下:
apt-file search gtk.h
但这样会返回很多的包,因此我们应该缩小搜索范围:apt-file search gtk/gtk.h
输出如下:root@falko-desktop:~/avant-window-navigator-0.1.1# apt-file search gtk/gtk.h
libgfcui-dev: usr/include/gfc-2.0/gfc/gtk/gtk.hh
libgtk+2.0-directfb-dev: usr/include/directfb/gtk-2.0/gtk/gtk.h
libgtk1.2-dev: usr/include/gtk-1.2/gtk/gtk.h
libgtk2.0-dev: usr/include/gtk-2.0/gtk/gtk.h
libgtk2.0-doc: usr/share/doc/libgtk2.0-doc/gtk/gtk.html
root@falko-desktop:~/avant-window-navigator-0.1.1#
你可以看到有三个软件包包含gtk/gtk.h(一个包含gtk/gtk.hh,另一个包含gtk/gtk.html,这两个软件包都不是我们想要的),现在由我们决定该安装哪个软件包。如果你不确定,你可以安装所有三个软件包,或者一个一个安装,并且每安装一个就测试一下编译错误是否还会出现。在本例中,正确的软件包是libgtk2.0-dev,因此我们安装该软件包:
apt-get install libgtk2.0-dev
现在我们重新启动编译过程:root@falko-desktop:~/avant-window-navigator-0.1.1# make
make all-recursive
make[1]: Entering directory `/root/avant-window-navigator-0.1.1'
Making all in src
make[2]: Entering directory `/root/avant-window-navigator-0.1.1/src'
if gcc -DHAVE_CONFIG_H -I. -I. -I.. -DORBIT2=1 -pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/libwnck-1.0 -I/usr/include/gconf/2 -I/usr/include/orbit-2.0 -DDATADIR=\""/usr/local/share"\" -DGNOMELOCALEDIR=\""/usr/local/share/locale"\" -g -O2 -Wall -pedantic -std=c99 -fno-strict-aliasing -fmessage-length=0 -D_FORTIFY_SOURCE=2 -MT main.o -MD -MP -MF ".deps/main.Tpo" -c -o main.o main.c; \
then mv -f ".deps/main.Tpo" ".deps/main.Po"; else rm -f ".deps/main.Tpo"; exit 1; fi
In file included from /usr/include/gtk-2.0/gtk/gtk.h:170,
from main.c:21:
/usr/include/gtk-2.0/gtk/gtktextbuffer.h:52: warning: ISO C restricts enumerator values to range of âintâ
/usr/include/gtk-2.0/gtk/gtktextbuffer.h:53: warning: ISO C restricts enumerator values to range of âintâ
/usr/include/gtk-2.0/gtk/gtktextbuffer.h:55: warning: ISO C restricts enumerator values to range of âintâ
In file included from main.c:28:
awn-app.h:30:29: error: libwnck/libwnck.h: No such file or directory
In file included from main.c:28:
awn-app.h:60: error: expected specifier-qualifier-list before âWnckWindowâ
awn-app.h:80: warning: struct has no members
awn-app.h:83: error: expected â)â before â*â token
main.c: In function âmainâ:
main.c:52: warning: unused variable âlabâ
make[2]: *** [main.o] Error 1
make[2]: Leaving directory `/root/avant-window-navigator-0.1.1/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/avant-window-navigator-0.1.1'
make: *** [all] Error 2
root@falko-desktop:~/avant-window-navigator-0.1.1#
正如你所看到的,最初的错误没有了,但是又有另一个文件缺失,libwnck/libwnck.h,因此我们再来搜索缺失的包:
apt-file search libwnck/libwnck.h
这一次我们很幸运,只有一个软件包包含该文件:root@falko-desktop:~/avant-window-navigator-0.1.1# apt-file search libwnck/libwnck.h
libwnck-dev: usr/include/libwnck-1.0/libwnck/libwnck.h
root@falko-desktop:~/avant-window-navigator-0.1.1#
因此我们安装该缺失的软件包:
apt-get install libwnck-dev
4、链接
- Debian: http://www.debian.org
- Ubuntu: http://www.ubuntu.com
- 在Debian和Ubuntu系统上利用apt-file查询缺失软件包
- Debian和Ubuntu系统的软件包管理工具
- 在debian/ubuntu中查询软件包的依赖关系
- APT软件包管理工具安装在redhat系统上
- 在树莓派(Debian系统)上安装python软件包pymssql
- 在树莓派(Debian系统)上安装python软件包pymssql
- Apt-get 如何在Ubuntu/Debian上正常工作
- ubuntu软件包管理系统之apt 和 dpkg原理
- 在Debian/Ubuntu上安装Trac系统
- Debian(Ubuntu) dpkg和apt
- ubuntu系统更改apt软件包源
- 在Ubuntu和debian上安装OpenCV
- Ubuntu使用apt-file解决库或者文件缺失依赖
- Ubuntu使用apt-file解决库或者文件缺失依赖
- Ubuntu使用apt-file解决库或者文件缺失依赖
- Ubuntu使用apt-file解决库或者文件缺失依赖
- Debian软件包管理工具apt-get和dpkg操作备忘
- [Ubuntu]软件包管理工具APT和DPKG命令
- 给软件工程师的自学建议
- gzlong的技术文章
- Objective-C语法之KVO的使用
- STL 简介,标准模板库 list
- 不含类的C++
- 在Debian和Ubuntu系统上利用apt-file查询缺失软件包
- C#通过OLEDB导出大数据到Excel
- [linker fatal error]:Expected a file name的解决办法
- 简单设置Win7操作系统有效保护视力
- 调用SignTool进行签名 VC++
- 递归下降法实现计算表达式
- Objective-C语法之动态类型(isKindOfClass, isMemberOfClass,id)等
- MySQL 修改phpmyadmin中mysql root的空改为新密码后,如何从phpmyadmin可登录
- Spring 的 BeanPostProcessor接口实现