Summary of usage of LIBXML2 Library in Windows environment

Source: Internet
Author: User
Tags gz file

(1)--construction of the environment, download and installation of LIBXML2 and Iconv

          LIBXML2 is a C-language XML library, It is simple and convenient to provide various operations on XML documents, and support XPath queries, as well as some of the features that support XSLT transformations. LIBXML2 is the http://xmlsoft.org/downloads.html, the full version of the library is open source, and with example programs and documentation. The full version of the file name is: libxml2-2.7.8.tar.gz.

          LIBXML2 The default inner code is UTF-8, All XML files that are processed using LIBXML2 must first be explicitly or by default converted to UTF-8 encoding to be processed.
to use Chinese in XML, you must be able to convert between UTF-8 and GB2312 (a more common type of Simplified Chinese encoding). LIBXML2 provides the default code conversion mechanism, and there is an example in LIBXML2 's tutorial, which proves that this example is not suitable for converting Chinese. So we need to explicitly use ICONV for the inner code conversion, LIBXML2 itself is also iconv use to convert. Iconv is a library dedicated to encoding conversions, and basically supports all the commonly used encodings today. It is a part of the GLIBC library and is often used in UNIX systems. Of course, there's no problem with using Windows.

It is http://gnuwin32.sourceforge.net/packages/libiconv.htm and the file name is Libiconv-1.9.2-1-lib.zip.

Libiconv-1.9.2-1-lib.zip decompression, the iconv.h into the C:\opt\include directory, the Libiconv.lib into C:\opt\lib, and renamed to Iconv.lib. (Create a new one without the OPT directory).

Unzip the libxml2-2.7.8.tar.gz file to the C Packing directory and store the makefile file for multiple Windows platform compilers in the C:\libxml2-2.7.8\libxml2-2.7.8\win32 directory, we use VS2008 , so you will use the Makefile.msvc file later.

1. Enter visual Studio Command Prompt;

2.CD C:\libxml2-2.7.8\libxml2-2.7.8\win32

3. Input cscript configure.js compiler=msvc prefix=c:\opt include=c:\opt\include lib=c:\opt\lib debug=yes, enter to execute.

4. Finally compile with the NMAKE command, enter nmake/f Makefile.msvc and return.

An error message appears,

MAKEFILE.MSVC (465): fatal error u1020:end-of-file found before next directive
Stop.

Online to find the next reason, the original is makefile.msvc in error.

+!if "$ (with_icu)" = = "1"

+libs = $ (LIBS) Icu.lib

+!endif

Delete the + number in front of the above three lines and re-execute NMAKE.

A bin.msvc directory is generated in the current Win32 directory, where Libxml2.lib and Libxml2.dll files are required for development.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.