Re: [xml] compilation problem with mingw



1 - Does it possible to use the "zlatkovic" binaries to compile under mingw
runtime .

I never succeeded.

To make it short : never succeded too. To make it a bit longer :

You can compile by playing with impdef and libtool ; it is quite simple, and it will compile and link, but as stated by Daniel in several mails in the archives, mix both compilers is not a good think, and you will face problems, as a xmlFree crash in my case. As it is easy, it is worth to try it on your project.

2 - Do I need to compile myself libxml2 under mingw ?
I had to do it myself but found it not exactely trivial.

Quite tricky indeed. If you do not need any special option you can use a DevPak for the IDE DevCPP (use mingw). If you do not want to use the DevCPP IDE, just rename .DevPak as .tar.bz2 and uncompress the contents. You will get all that you need.

Because I ran into linking problems with xmlFree, I made those at http://people.via.ecp.fr/~remi/dist/devpacks/index.php3 (libxml + libxslt) in static link (won't link in DLL mode)
It is based on 2.6.16, but I won't be able to update it frequently.


As it is very closed to a mail I sent to the list in the beginning of march, but which may have been lost (never been received on the list), I copy it below. (For those interested, the Linux part of the problem was by-passed by using xmlParseFile instead of xmlCtxtReadFile)


--
Rémi Peyronnet

-----------------
Date: Fri, 04 Mar 2005 00:52:25 +0100
From: =?ISO-8859-15?Q?R=E9mi_Peyronnet?= <remi peyronnet via ecp fr>
To:  xml gnome org
Subject: Crash with xmlFree on GCC/Linux, Mingw and VS

Hi,

In order to distribute properly an opensource project using libxml2, I
would like to make it build with several environments :
  - gcc / Linux
  - Mingw / Win32
  - Visual Studio / Win32

By now, only the vs 2.6.7 build is working completly (but 2.6.17
crashes). Mingw only work in static build, and gcc builds keep crashing
in xmlFree.

Here is my configuration :
  - VS : libxml2 2.6.7 / libxml2 2.6.17
  - Mingw : (the one shipped with Dev-CPP 4.9.9.0) libxml2 2.6.7
compiled for VS, or libxml2 2.6.16 compiled by mingw
  - Linux : (debian/sarge, gcc 3.3.5) libxml2 2.6.16 shipped bu debian
(2.6.16-3), or self compiled (2.6.16)

I reproduced the two problems in a simple test program
(http://people.via.ecp.fr/~remi/soft/xml/xmldiff/libxml2-xmlfree-test.tar.bz2).

By searching FAQ and archives, I have seen that xmlFree problems were
often due to library problems, and often solved by a static link.

1/ GCC / Linux

The crash is a segfault, with the following backtrace :

#0  0x4108b284 in mallopt () from /lib/libc.so.6
#1  0x4108a09f in free () from /lib/libc.so.6
#2  0x08066339 in xmlNodeSetContent (cur=0x411485e0,

and valgrind reports a "Invalid free() / delete / delete[]"

I tried several things :
  - with debian packages on two different distribution
  - with a libxml2 2.6.16 manual build
  - with a libxml2 2.6.1 manual build (I am pretty sure it had worked in
the past !)
  - with a libxml2 2.6.16 static build
  - use xmlGcMemSetup

It keeps crashing. Am I doing something wrong in the code ?

I am now desparate : I moved from xerces to libxml2 a while ago, because
libxml2 is a lot more powerful and smarter about memory ; but now I have
no idea of what to do to make it work on Linux.

2/ Mingw [partially solved]

So I tried to recompile libxml2 with mingw. Build process works well,
but when linking to my program, it fails on "[Linker error] undefined
reference to `_imp__xmlFree' ".

By linking statically, it works, and don't crash. Good news, but if
anyone has an idea to make it work with shared library, that would be
nice :-)

Many thanks in advance for any hint, and thanks again for libxml2.

--
Rémi Peyronnet



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