用GSF(GNOME结构化文档库)库查看压缩文件的内容

           用GSF库查看压缩文件的内容                            
GSF(GNOME结构化文档库)是一个读写复合文档的I/O高度抽象的链接库,在GNU LGPL条件下发布。依赖于glib库

怎么使用这个文档库,

可以看里面的测试用的例子
例如: tests/test-ls-zip.c 是查看一个压缩文件里面包含的文件列表。

首先需要编译通过,
g++  test-ls-zip.c
编译器会报一些头文件找不到,
test-ls-zip.c:1:33: 错误: gsf/gsf-input-stdio.h:没有该文件或目录

那我们就添加选项使编译器能找到这几个文件
 g++  -I/usr/include -I/usr/include/libgsf-1 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include  test-ls-zip.c/tmp/ccdhVO7i.o: In function `test(int, char**)':
test-ls-zip.c:(.text+0x56): undefined reference to `gsf_input_stdio_new'
test-ls-zip.c:(.text+0x82): undefined reference to `g_return_if_fail_warning'
test-ls-zip.c:(.text+0xc3): undefined reference to `g_log'
test-ls-zip.c:(.text+0xce): undefined reference to `g_error_free'
test-ls-zip.c:(.text+0xe5): undefined reference to `gsf_input_uncompress'
test-ls-zip.c:(.text+0xfa): undefined reference to `gsf_infile_zip_new'
test-ls-zip.c:(.text+0x110): undefined reference to `g_type_check_instance_cast'
test-ls-zip.c:(.text+0x118): undefined reference to `g_object_unref'
test-ls-zip.c:(.text+0x141): undefined reference to `g_return_if_fail_warning'
test-ls-zip.c:(.text+0x182): undefined reference to `g_log'
test-ls-zip.c:(.text+0x18d): undefined reference to `g_error_free'
test-ls-zip.c:(.text+0x1b4): undefined reference to `gsf_infile_child_by_index'
test-ls-zip.c:(.text+0x1c2): undefined reference to `gsf_input_size'
test-ls-zip.c:(.text+0x1d1): undefined reference to `gsf_input_name'
test-ls-zip.c:(.text+0x1e9): undefined reference to `g_print'
test-ls-zip.c:(.text+0x1fc): undefined reference to `g_type_check_instance_cast'
test-ls-zip.c:(.text+0x204): undefined reference to `g_object_unref'
test-ls-zip.c:(.text+0x213): undefined reference to `gsf_infile_num_children'
test-ls-zip.c:(.text+0x230): undefined reference to `g_type_check_instance_cast'
test-ls-zip.c:(.text+0x238): undefined reference to `g_object_unref'
/tmp/ccdhVO7i.o: In function `main':
test-ls-zip.c:(.text+0x2a6): undefined reference to `gsf_init'
test-ls-zip.c:(.text+0x2c5): undefined reference to `gsf_shutdown'
collect2: ld 返回 1

链接时出错,需要找到动态链接库,添加编译选项-lgsf-l

 g++  -I/usr/include -I/usr/include/libgsf-1 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include  -lgsf-1  test-ls-zip.c
编译通过,生成a.out,
可以运行了 ./a.out zz.zip 就可以查看zip文件的内容。

我们不要a.out, 需要在添加-o test-ls-zip
 g++  -I/usr/include -I/usr/include/libgsf-1 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include  -lgsf-1  -o test-ls-zip test-ls-zip.c

现在就可以自由使用test-ls-zip,也可以在代码中使用这个库了。

参考资料
http://projects.gnome.org/libgsf/index.html
http://svn.gnome.org/viewvc/libgsf/trunk/
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值