After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 327512 - build with win32 host broken if --disable-shared is given
build with win32 host broken if --disable-shared is given
Status: RESOLVED NOTGNOME
Product: libxml2
Classification: Platform
Component: general
2.6.22
Other Linux
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2006-01-18 10:49 UTC by tim.vanholder
Modified: 2006-01-18 12:26 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description tim.vanholder 2006-01-18 10:49:32 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/...)
Comment 1 Daniel Veillard 2006-01-18 12:26:06 UTC
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