Re: [xml] xmlDocDump() on Windows



On Fri, Sep 14, 2007 at 08:06:22AM +0200, Trappel Martin wrote:
Daniel Corbe wrote:
/* Begin code snippet */
xmlDocPtr mtp3;
FILE *xml;

mtp3 = xmlReadFile(config->MTP3filename, NULL, 0); xml =
fopen(config->MTP3filename, FOPEN_MODE_OVERWRITE); if (!xml ||
ferror(xml)) {

outputf("ERROR WRITING MTP3 XML File: %s\n", strerror(errno)); } else
{ xmlDocDump(xml, mtp3); fclose(xml); }
(...)
I've tried building my app on both debug and release, and the same thing happens.
You're saying there may be something wrong with my build environment?
(...)
      libxml2-2.6.30 (binary) as gotten from:
      http://www.zlatkovic.com/libxml.en.html


This cannot work.
You cannot reliably work with FILE* as a parameter to any dll unless you are 100% sure that it uses 
_exactly_ the same runtime version.

Now, the prebuilt version of libxml2 links against MSVCRT.dll (as it is built using VC6, afaik)

You however, using VC8, are linking your program against an exact version of MSVCR80?.dll which you can 
find in the WINDOWS/WinSxS directory.

If you want to use any libxml2 function that relies on runtime lib structures like FILE* you have to 
compile it yourself against the same msvcr* version as your application.

Personally, I would avoid these functions and use something like xmlDocDumpFormatMemory to write the tree 
to memory and save that to a file.

  I don't use windows, but from the past discussions, I believe this to
be exact and the problem faced by the person reporting the crash. FILE *
seems to be completely incompatible between versions of runtimes if they
are not 100% the same. To me this is a bug in the ABI garantees of the
Windows compilers and absolutely not a libxml2 problem. 
  Solution is to recompile libxml2 with your compiler and flags or avoid
any API using FILE *.

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]