GNOME Bugzilla – Bug 596239
Regression: unable to compile C++ programs with mingw C++ compiler anymore
Last modified: 2017-09-07 18:11:56 UTC
Hi, Recently a change was done to attempt to fix bug 590302 and 561340. This was done at http://git.gnome.org/cgit/libxml2/commit/?id=a194ccb8d19ddde94c2c04ddf197e6a629f7cc9b Unfortunately a regression was introduced by this change. When using the (Fedora) MinGW (cross-)compiler the compilation of C++ source code which require libxml2 headers always fails. Here's a simple testcase: ----------- #include <libxml/parserInternals.h> int main() { return 0; } ----------- Here's the complete GCC output when trying to compile this as C++ code: $ i686-pc-mingw32-g++ testxml.cc -o testxml.exe -I/usr/i686-pc-mingw32/sys-root/mingw/include/libxml2/ In file included from /usr/i686-pc-mingw32/sys-root/mingw/include/libxml2/libxml/parserInternals.h:18, from testxml.cc:1: /usr/i686-pc-mingw32/sys-root/mingw/include/libxml2/libxml/chvalid.h:80: error: external linkage required for symbol 'xmlIsBaseCharGroup' because of 'dllexport' attribute /usr/i686-pc-mingw32/sys-root/mingw/include/libxml2/libxml/chvalid.h:80: error: uninitialized const 'xmlIsBaseCharGroup' /usr/i686-pc-mingw32/sys-root/mingw/include/libxml2/libxml/chvalid.h:124: error: external linkage required for symbol 'xmlIsCharGroup' because of 'dllexport' attribute /usr/i686-pc-mingw32/sys-root/mingw/include/libxml2/libxml/chvalid.h:124: error: uninitialized const 'xmlIsCharGroup' /usr/i686-pc-mingw32/sys-root/mingw/include/libxml2/libxml/chvalid.h:136: error: external linkage required for symbol 'xmlIsCombiningGroup' because of 'dllexport' attribute /usr/i686-pc-mingw32/sys-root/mingw/include/libxml2/libxml/chvalid.h:136: error: uninitialized const 'xmlIsCombiningGroup' /usr/i686-pc-mingw32/sys-root/mingw/include/libxml2/libxml/chvalid.h:156: error: external linkage required for symbol 'xmlIsDigitGroup' because of 'dllexport' attribute /usr/i686-pc-mingw32/sys-root/mingw/include/libxml2/libxml/chvalid.h:156: error: uninitialized const 'xmlIsDigitGroup' /usr/i686-pc-mingw32/sys-root/mingw/include/libxml2/libxml/chvalid.h:176: error: external linkage required for symbol 'xmlIsExtenderGroup' because of 'dllexport' attribute /usr/i686-pc-mingw32/sys-root/mingw/include/libxml2/libxml/chvalid.h:176: error: uninitialized const 'xmlIsExtenderGroup' /usr/i686-pc-mingw32/sys-root/mingw/include/libxml2/libxml/chvalid.h:190: error: external linkage required for symbol 'xmlIsIdeographicGroup' because of 'dllexport' attribute /usr/i686-pc-mingw32/sys-root/mingw/include/libxml2/libxml/chvalid.h:190: error: uninitialized const 'xmlIsIdeographicGroup' /usr/i686-pc-mingw32/sys-root/mingw/include/libxml2/libxml/chvalid.h:191: error: external linkage required for symbol 'xmlIsPubidChar_tab' because of 'dllexport' attribute /usr/i686-pc-mingw32/sys-root/mingw/include/libxml2/libxml/chvalid.h:191: error: uninitialized const 'xmlIsPubidChar_tab' In file included from testxml.cc:1: /usr/i686-pc-mingw32/sys-root/mingw/include/libxml2/libxml/parserInternals.h:279: error: external linkage required for symbol 'xmlStringText' because of 'dllexport' attribute /usr/i686-pc-mingw32/sys-root/mingw/include/libxml2/libxml/parserInternals.h:279: error: uninitialized const 'xmlStringText' /usr/i686-pc-mingw32/sys-root/mingw/include/libxml2/libxml/parserInternals.h:279: error: storage size of 'xmlStringText' isn't known /usr/i686-pc-mingw32/sys-root/mingw/include/libxml2/libxml/parserInternals.h:280: error: external linkage required for symbol 'xmlStringTextNoenc' because of 'dllexport' attribute /usr/i686-pc-mingw32/sys-root/mingw/include/libxml2/libxml/parserInternals.h:280: error: uninitialized const 'xmlStringTextNoenc' /usr/i686-pc-mingw32/sys-root/mingw/include/libxml2/libxml/parserInternals.h:280: error: storage size of 'xmlStringTextNoenc' isn't known /usr/i686-pc-mingw32/sys-root/mingw/include/libxml2/libxml/parserInternals.h:281: error: external linkage required for symbol 'xmlStringComment' because of 'dllexport' attribute /usr/i686-pc-mingw32/sys-root/mingw/include/libxml2/libxml/parserInternals.h:281: error: uninitialized const 'xmlStringComment' /usr/i686-pc-mingw32/sys-root/mingw/include/libxml2/libxml/parserInternals.h:281: error: storage size of 'xmlStringComment' isn't known When compiling C source code, the compile error doesn't occur, just some warnings: $ i686-pc-mingw32-gcc testxml.c -o testxml.exe -I /usr/i686-pc-mingw32/sys-root/mingw/include/libxml2/ /usr/i686-pc-mingw32/sys-root/mingw/include/libxml2/libxml/parserInternals.h:279: warning: array 'xmlStringText' assumed to have one element /usr/i686-pc-mingw32/sys-root/mingw/include/libxml2/libxml/parserInternals.h:280: warning: array 'xmlStringTextNoenc' assumed to have one element /usr/i686-pc-mingw32/sys-root/mingw/include/libxml2/libxml/parserInternals.h:281: warning: array 'xmlStringComment' assumed to have one element When performing a small change in the headers, the compile error doesn't occur anymore: --- xmlexports.h.orig 2009-09-25 00:00:03.511532978 +0200 +++ xmlexports.h 2009-09-25 00:00:15.684782702 +0200 @@ -139,7 +139,7 @@ @@ -115,7 +115,7 @@ */ #if !defined(LIBXML_STATIC) #define XMLPUBFUN __declspec(dllexport) - #define XMLPUBVAR __declspec(dllexport) + #define XMLPUBVAR __declspec(dllexport) extern #else #define XMLPUBFUN #if !defined(LIBXML_STATIC)