LIBXML2 connection error problem in MinGW Xmlfree

Source: Internet
Author: User
Tags microsoft c

LIBXML2 connection error problem in MinGW XmlfreeOctober 02, 2013 ⁄ general ⁄ a total of 1527 characters ⁄ font size small medium big ⁄ comments off

Original address: http://blog.csdn.net/hongqun/article/details/6009684

LIBXML2 is a very useful XML library, the official website is http://www.libxml.org/, but God knows for what reason, this page cannot be accessed.

Finally download down, in the MinGW but a lot of problems.

First question:

That is, the compilation passed, but the functions such as xmlfree were not found during the linking process.

Online someone said, modify the Xmlexports.h file, refer here: http://blog.sina.com.cn/s/blog_4f183d960100dt2i.html and here: http://mail.gnome.org/ Archives/xml/2004-february/msg00007.html. Can barely compile through. But always feel that modifying the library's header file is not a good practice. Finally I found out, in the xmlexports.h there is such a paragraph:

The comment section is about the problem. I simply defined the in_libxml into the code, and the compilation was no problem. (The definition of reprinted tip:in_libxml should precede the introduction of the Libxml header file)

But I was so happy that I was too early.

second question:

The program crashes as soon as it runs! GdB looked and xmlfree! again.

It turns out that LIBXML2 's Windows binaries are compiled with Microsoft C, and in general, Pexport and Dlltool in MinGW can be linked to a dynamic library and work properly, except for static data in DLL libraries. Xmlfree, Xmlmalloc, and Xmlrealloc in LIBXML2 are all in the form of static variables. Specific reasons can be seen here: http://www.linuxquestions.org/questions/programming-9/[solved] using-libxml2-on-mingw-xmlfree-crashes-839802/

The workaround is to add the DLL variables after the xmlparsefile or other XML functions are initialized:

if (!xmlfree) xmlmemget (&xmlfree,&xmlmalloc,&xmlrealloc,null);

To solve the problem.

LIBXML2 connection error problem in MinGW Xmlfree

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.