Fedaora14 下编译xerces+icu

10 篇文章 0 订阅

Fedaora14 下编译xerces+icu

Xerces 是解析xml的库。

使用icu可以支持中文。

 

下载ICUxerces 软件

官网是:http://www.icu-project.org/

ftp://ftp.software.ibm.com/software/globalization/icu/3.4下载icu-3.4.tgzx.

 

本从已经下载了icu4c-3_6-src.tar xerces-c-3.1.1.tar

编译icu

首先编译安装icu.  默认是在64位编译,如果需求32位编译,请参与网上其他的帖子。

1.      解压icu.  Tar -xficu4c-3_6-src.tar  解压出的目录为:icu

 

2.      设置环境变量

Export ICUROOT=xxx/xxx/xml/icu64

Echo $ICUROOT

Export LIBPATH=xxx/xxx/xml/icu64/lib:LIBPATH

Echo $LIBPATH

Export PATH=xxx/xxx/xml/icu64/bin:$PATH

Echo $PATH

 

3.      Cd到步骤1解压出来的目录icu下的source目录.  Cd /xxx/icu/source.

4.      Configure

./Configure --prefix=xxxx/xxx/xml/icu64 --disable-shared --enable-static

5.      Gmake

6.      Make install

 

可能会报错误:

ParagraphLayout.cpp:801:6:错误: #elif 后没有表达式

本文直接到错的文件里,在#elif 后加上班1. #elif 1. 永远为真。

 

 

编译xerces

编译xerces 的步骤与icu类似:

1.  解压xerces-c-3.1.1.tar  解压出的目录是xerces-c-3.1.1

Tar -xf xerces-c-3.1.1.tar

 

2.  设置环境变量

Export XERCESROOT=xxx/xxxx/xerces-c-3.1.1

设置为xerces-c解压出来的目录。

Export LIBPATH=xxx/xxxx/xerces-c-3.1.1:$LIBPATH

3.  Cd xerces-c-3.1.1.

4.  Configure --enable-transcoder-icu --endable-msgloader-icu--prefix=/xxx/xxx/xml/xerces --disable-shared

5.  Gmake

6.  Make install

 

 

验证:

看看能不能转换成汉字编码,如失败,运行示例会有下列错误:

Could not create a converter fpr encoding:GBK

 

编译成功后,可使用XERCESROOT/bin/运行demo

./SAX2Pirnt –x=GBK test.xml

  

 

Makefile 环境

可以看一下安装目录的include lib

Cd /xxx/xxx/xerces;ls

include lib以及bin目录:

其中lib目录下面有2个文件和一个目录pkgconfig

Libxerces-c.a  libxerces-c.la  pkgconfig

 

Libxerces-c.la pkgconfig其实说明makefile里面要如何添加路径和参数。

lib include 两个文件cp到工程目录下。

makefile中加入库xerces-c

L../libxml/xerces-c  -lnsl –lpthread–lcurl

注意:这里要加上-lnsl –lpthread –lcurl. libxerces-c.la里有说明。否则demo会编译不过

包括头文件路径:

I../inc_xml

 

这样,xerces+icu就应用到工程中了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值