GNOME Bugzilla – Bug 327512
build with win32 host broken if --disable-shared is given
Last modified: 2006-01-18 12:26:06 UTC
If a windows target is used (in my case, I'm crosscompiling from debian linux to mingw32) and --disable-shared is given (in order to only build a static library), the resulting library cannot be used (and as a result the build fails when making xmllint (or most other executables)). The cause is xmlexports.h - this assumes that LIBXML_STATIC will be defined if the user wants to link with the static library, otherwise it marks some functions and/or variables as DLL exports/imports. While this is reasonable behaviour if both shared and static versions of the library are built, it is not reasonable in the case only a static library is built. In this case, most programs that use libxml2 (including xmllint, xmlcatalog and most, but not all examples) will fail to link, because the linker looks for the dllimport version of __xmlFree. This is easy enough to fix, however - the configure script could easily detect that shared libraries are disabled and add -DLIBXML_STATIC to CFLAGS and XML_CFLAGS. This would also cause xml2-config to include that definition in its --cflags output, and all well-behaved client programs would automagically get the correct settings. Example (modified from an existing $host check): case ${host} in *-*-solaris*) XML_LIBDIR="${XML_LIBDIR} -R${libdir}" ;; hppa*-hp-mpeix) NEED_TRIO=1 ;; *-*-mingw* | *-*-cygwin* | *-*-msvc* ) # If the host is Windows, and shared libraries are disabled, we need to # add -DLIBXML_STATIC to CFLAGS in order for linking to work properly # (without it, xmlexports.h would force the use of DLL imports, which # obviously aren't present in a static library). if test "x$enable_shared" = "xno"; then XML_CFLAGS="$XML_CFLAGS -DLIBXML_STATIC" CFLAGS="$CFLAGS -DLIBXML_STATIC" fi ;; esac (note: the above case may not yet match all relevant host triplets; both CFLAGS and XML_CFLAGS need to be set to get both the desired xml2-config and a working link of xmllint/xmlcatalog/...)
This is not within the scope of GNOME. This kind of changes may affect users which don't check GNOME bugzilla, so this need to be reported on the mailing list not here. I'm not against the change, I'm just opposed to make it just with the feedback received on a GNOME bugzilla context. So post to the mailing list, see http://xmlsoft.org/bugs.html Daniel