您好,欢迎访问一九零五行业门户网

libxml2 安装使用

libxml2 安装使用 现在的最新版本是2.6.30,可以到http://ftp.gnome.org/pub/gnome/sources/libxml2/2.6/ 下载。 安装很简单,三部走。 view plaincopy to clipboardprint? 01安装 02.#./configure 03.#make 04.#make install 05测试 06.#make tests 07卸载
libxml2 安装使用
现在的最新版本是2.6.30,可以到http://ftp.gnome.org/pub/gnome/sources/libxml2/2.6/ 下载。
  安装很简单,三部走。
view plaincopy to clipboardprint?
01安装
02.#./configure  
03.#make  
04.#make install  
05测试  
06.#make tests  
07卸载
08.#make uninstall
如果不需要特别的定制,在configure阶段可以直接默认。 libxml2将默认把头文件与库安装在/usr/local/include/libxml2/libxml目录下。因此可能会让你在第一次编译自己的程序时遇到头文件“no such file”的错误
libxml2提供了解决方法,它很体贴地在/usr/local/bin目录下为您提供了xml2-config、xmlcatalog、xmllint三个便利的工具。其中xml2-config在编译时用得到。
[root@amanda ~]# xml2-config
usage: xml2-config [option]
known values for option are:
  --prefix=dir          change libxml prefix [default /usr/local]
  --exec-prefix=dir     change libxml exec prefix [default /usr/local]
  --libs                print library linking information
  --cflags              print pre-processor and compiler flags
  --modules             module support enabled
  --help                display this help and exit
  --version             output version information
这里说到编译时用到的参数: --cflags和--libs,帮助上说明这个为工程编译时提供辅助。它们提供的信息如下:
view plaincopy to clipboardprint?
01.[root@amanda ~]# xml2-config --cflags  
02.-i/usr/local/include/libxml2  
03.[root@amanda ~]# xml2-config --libs  
04.-l/usr/local/lib -lxml2 -lz -lm 
[root@amanda ~]# xml2-config --cflags
-i/usr/local/include/libxml2
[root@amanda ~]# xml2-config --libs
-l/usr/local/lib -lxml2 -lz -lm
所以在编译自己的测试程序时,可以直接使用 #gcc -i /usr/local/include/libxml2 -l/usr/local/lib -lxml2 -lz -lm  -o test test.c 。
或者加入到makefile中,例如:
cflags=`xml2-config --cflags`
libs=`xml2-config --libs`
注:若编译出错:
/usr/include/bits/fcntl2.h:51: 错误: 调用‘__open_missing_mode’,声明有错误属性:open with o_creat in second argument needs 3 arguments
解决方法:
打开目录下的nanohttp.c,第1588行由
fd = open(filename, o_creat | o_wronly);更换为
fd = open(filename, o_creat | o_wronly,0777);
参考资料:
http://temix.blog.163.com/blog/static/364133200810237854799/
http://linux.chinaunix.net/techdoc/system/2008/11/08/1044060.shtml
https://bugs.launchpad.net/ubuntu/+source/gcc-4.3/+bug/286565
其它类似信息

推荐信息