[libxml++] Strange linker error building a libxml++ app with MinGW



Hello,

Having used libxml++ successfully in a Linux environment, I'm having a bit
of a job getting it to work in Windows (XP; MinGW; gcc 3.4.2).

I'm using 1.0.4, so the only dependency is straight libxml2. I compiled
libxml2 using the supplied MinGW makefile (which needed a little tweaking
as it had syntax errors!) and ended up with a static library libxml2.a,
which I installed in the appropriate directory.

However, lacking a full Cygwin environment (I do not want the application I
am writing to depend on Cygwin shared libraries) I built libxml++ in a
somewhat non-ustandard way. This involved basically moving round the
directories and creating a simple makefile where each libxml++ source file
was compiled using:

g++ -c -Ic:\mingw\include  file.cc

i.e. no preprocessor directives. I also #ifdef'ed out the stuff in
api_export.h, as I did not want a DLL of libxml++, just a static library,
and the stuff in api_export.h was causing the compilation to throw up all
manner of warnings and errors.

libxml++ successfully built that way, and I ended up with a libxml++.a
which I moved to the appropriate lib directory.

However when I attempted to compile a small sample libxml++ program:

#include <libxml++/libxml++.h>

int main()
{
      xmlpp::SaxParser p;
      return 0;
}

compilation was successful, but linking, with

g++ -o test.exe test.o -Lc:\mingw\lib -lxml++ -lxml2

I got all manner of obscure linker errors spewed out, e.g.:

undefined reference to _imp_ZN5xmlpp9SaxParser1Eb
undefined reference to _imp__xmlFree
undefined reference to _imp_ZN5xmlpp11ContentNodeC2EP8_xmlNode

and on and on for about 20 lines. The same thing happened when I attempted
to compile my FLTK-based GUI application with libxml++; it works fine with
the XML parsing code commented out (i.e. I can compile and build an FLTK
application under my environment) but spewed weird linker errors when I
attempted to link in libxml2/libxml++.

I think these sorts of linker errors, featuring internal compiler types,
are normally to do with mixing source compiled with one compiler version
and libraries compiled with another, aren't they? However in my case
everything was compiled with gcc/g++ 3.4.2 (supplied with the latest
MinGW).

One final observation is that the samples that come with straight libxml2
compiled (as part of the libxml2 make process) and ran fine.
I'm guessing I did not include a crucial preprocessor directive when
compiling libxml++.....

I should add that I have little experience of compiling stuff under
Windows, other than under Visual C++, which I don't have on my current
system (and besides, I want to attempt to use only free software within my
installation of Windows!)

Thanks,
Nick






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