I'm trying to build libxml2 from source (git), and linker keeps
complaining about multiple definition of variables between SAX.c and
other source files, like this:
.libs/entities.o: In function `xmlDumpEntityContent':
f:\src\libxml2/entities.c:879: multiple definition of `forbiddenExp'
.libs/SAX.o:f:\src\libxml2/SAX.c:43: first defined here
because both SAX.c and entities.c (in this particular example) define
IN_LIBXML and include various headers (such as global.h, xmlregexp.h and
other)
According to xmlexports.h, when LIBXML_STATIC is not defined (in my case
it definitely isn't) and IN_LIBXML is defined (it is, see above),
XMLPUBVAR is defined as
#define XMLPUBVAR __declspec(dllexport)
Interestingly, for Borland compiler XMLPUBVAR is defined as
#define XMLPUBVAR __declspec(dllexport) extern
and changing MinGW section to use the same definition fixes multiple
definition errors for me.
>From 5cb4370610016ea2043e172875c8ea100bc190c4 Mon Sep 17 00:00:00 2001
From:
=?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?=
<[email protected]>
Date: Fri, 30 Apr 2010 19:08:45 +0400
Subject: [PATCH 2/2] Fix MinGW multiple definition errors
---
include/libxml/xmlexports.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/include/libxml/xmlexports.h b/include/libxml/xmlexports.h
index 9c6790c..c6516b4 100644
--- a/include/libxml/xmlexports.h
+++ b/include/libxml/xmlexports.h
@@ -115,7 +115,7 @@
*/
#if defined(IN_LIBXML) && !defined(LIBXML_STATIC)
#define XMLPUBFUN __declspec(dllexport)
- #define XMLPUBVAR __declspec(dllexport)
+ #define XMLPUBVAR __declspec(dllexport) extern
#else
#define XMLPUBFUN
#if !defined(LIBXML_STATIC)
--
1.7.0.2.msysgit.0
_______________________________________________
xml mailing list, project page http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml