libxml2 + iconv + msvc 在windows下生成使用库
为了跨平台的解析xml,偶然获得Linux下比较好用的一个xml的解析库libxml2
,使用起来确实比较简单,方便;但移植到windows下后发下使用上存在问题:
无法解析格式位GB2312
类型的XML文件,但由于一些外部因素,Windows下必须使用GB2312
格式
在网上查看了诸多教程,有很多编译生成libxml2
库的文章,但都不支持iconv
,仔细阅读README
后,终于生成了可用的libxml2.lib
库,记录下来备用
操作系统:windows 7 x64
版本:libiconv-1.15, libxml2 Github版本
Visual Studio版本:vs2015
Cygwin:x64
以下操作皆为生成x64位库,32位的基本类似,可以查看具体的README。
一、生成iconv.lib
库
下载 libiconv-1.xx.tar.gz
在1.15中,需要阅读README.windows
,在1.16中需要阅读INSTALL.windows
,其余版本的类似,找到windows版本的安装说明。
三种方式可以编译安装libiconv
库,我这里使用的是第二种,使用MSVC
安装,这个是VS种安装的C/C++工具链,一般都已经安装。
There are three ways to create binaries of this package for Microsoft Windows:
- Native binaries, built using the mingw tool chain. 2) Native
- binaries, built using the MS Visual C/C++ tool chain. 3) Binaries for
- the Cygwin environment.
根据说明:
This recipe requires also a Cygwin environment (with 'bash', the common POSIX
commands, and 'make') as a build environment. Building with 'nmake' is not
supported.
For this, you need to install
* Cygwin (from https://cygwin.com/),
* some packages available from the Cy