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