You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by David Daeschler <da...@rsaisp.com> on 2007/09/04 14:47:45 UTC
Makefile.incl under MINGW
[sorry if this gets to you twice, I sent it from the wrong e-mail
account the first time]
Hello list,
Recently a bug has been found in the dllwrap tool for MINGW that causes
relocation sections inside a DLL to be duplicated. When the DLL has to
be relocated, addresses are fixed up twice causing crashes that are hard
to track down.
See
http://sourceforge.net/mailarchive/forum.php?thread_name=1187200750.8500.38.camel%40devit.rsaisp.com&forum_name=mingw-users for reference
I noticed that in the downloaded source for xerces-c 2.8.0 there is a
file inside of src/xercesc called Makefile.incl that includes the
following section starting at line 461:
#=============== MINGW SPECIFIC OPTIONS =========================
ifeq (${PLATFORM}, MINGW)
PLATFORM_COMPILE_OPTIONS = -D${PLATFORM} -fexceptions -D__GNUWIN32__
-DWIN32 -D_WINDOWS -DNDEBUG -DPLATFORM_WIN32
ifeq (${LIBTYPE},shared)
MAKE_SHARED = dllwrap --export-all-symbols --driver-name ${CXX}
${LDFLAGS}
MAKE_SHARED_C = ${CC} -D${PLATFORM} ${LDFLAGS}
else
PLATFORM_COMPILE_OPTIONS += -DXML_LIBRARY # switch off import/export
endif
ALLLIBS = ${LIBS}
SHLIBSUFFIX=.dll
endif
The line that reads:
MAKE_SHARED = dllwrap --export-all-symbols --driver-name ${CXX}
${LDFLAGS}
can be changed to:
MAKE_SHARED = ${CXX} -shared ${LDFLAGS}
To avoid the bug in dllwrap.
I did notice that when I downloaded trunk from CVS that I could not find
a reference to dllwrap anywhere, nor Makefile.incl. Maybe this has
already been addressed?
Thank you for your time,
- Dave
Re: Makefile.incl under MINGW
Posted by David Daeschler <da...@rsaisp.com>.
Hi Boris,
> Do you know if in this case all symbols will be exported (as is done
> in Xerces-C++ right now) or import/export declarations should be
> used?
MINGW supports __declspec(dllexport) and __declspec(dllimport) or by
default, exports all symbols when -shared is used. If you export all
symbols, MINGW's gcc allows you to link directly to the built DLL and
will "auto-import" the symbols.
If you use explicit exports/imports you can have g++ create an import
library when linking. A highly simplified command line would then look
like this:
(-mthreads includes multi-thread support, -shared says we're building a
DLL)
g++ -mthreads -shared $(LIBDIRS) $(LIBS) $(OBJECTS) -o libblah.dll
-Wl,--out-implib,libblah.a
> Also, I wonder why Xerces-C++ exports all symbols on Mingw even if
> the appropriate declarations are present (see the Mingw sections in
> util/Compilers/GCCDefs.hpp).
I can't find that file in the sources I checked out?
- Dave
Re: Makefile.incl under MINGW
Posted by Boris Kolpackov <bo...@codesynthesis.com>.
Hi David,
David Daeschler <da...@rsaisp.com> writes:
> I know that creating a .dll is as easy as specifying -shared on the
> g++ command line.
Do you know if in this case all symbols will be exported (as is done
in Xerces-C++ right now) or import/export declarations should be
used?
Also, I wonder why Xerces-C++ exports all symbols on Mingw even if
the appropriate declarations are present (see the Mingw sections in
util/Compilers/GCCDefs.hpp). Alberto, any ideas on that?
Boris
--
Boris Kolpackov
Code Synthesis Tools CC
http://www.codesynthesis.com
Open-Source, Cross-Platform C++ XML Data Binding
Re: Makefile.incl under MINGW
Posted by David Daeschler <da...@rsaisp.com>.
Hi Alberto,
> Creating library file: .libs/libxerces.dll.a...
> c:\MinGW\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe:
> BFD 2.15.91 20040904 assertion fail ../../src/bfd/cofflink.c:1929
>
> Can you have a look and suggest why this happens?
Unfortunately without knowing why the config scripts won't build a DLL
in the first place it is difficult to get to the root of the problem.
Maybe something is missing from the build configurations to support DLLs
under mingw? I know that creating a .dll is as easy as specifying
-shared on the g++ command line. As I'm not familiar with using
autoconf/libtool, I can't provide insight into it's use. Maybe someone
else on the list understands more?
Why do you have to specify -no-undefined at all? I see alot of stuff
about no-undefined, but I don't understand why the final link can't
build a DLL against all the static libraries that appear to be created
during the compilation?
I'm afraid I don't know enough about the build process to go any
further. The only thing I might suggest is upgrading your compiler and
binutils to the latest versions offered at mingw.org and see if that
fixes the crash.
- Dave
Re: Makefile.incl under MINGW
Posted by Alberto Massari <am...@datadirect.com>.
Hi David,
speaking of MINGW and dllwrap... if you build Xerces 3.0 using the
provided autoconf+libtool infrastructure, you will get only a static
library. If you add the LDFLAGS=-no-undefined option, it will attempt
to build also the dll version of the library, but the linker will crash
Creating library file: .libs/libxerces.dll.a...
c:\MinGW\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe:
BFD 2.15.91 20040904 assertion fail ../../src/bfd/cofflink.c:1929
Can you have a look and suggest why this happens?
Thanks,
Alberto
At 14.53 04/09/2007 +0200, Boris Kolpackov wrote:
>Hi David,
>
>David Daeschler <da...@rsaisp.com> writes:
>
> > The line that reads:
> >
> > MAKE_SHARED = dllwrap --export-all-symbols --driver-name ${CXX}
> > ${LDFLAGS}
> >
> > can be changed to:
> >
> > MAKE_SHARED = ${CXX} -shared ${LDFLAGS}
> >
> > To avoid the bug in dllwrap.
>
>If only you tested the release candidate and reported this a few days
>ago, before the 2.8.0 release... Hopefully MINGW folks will fix the
>bug in dllwrap.
>
>One way to work around this without changing Makefile.incl is to build
>Xerces-C++ as static library. For that add -s to the runConfigure
>command line.
>
>
> > I did notice that when I downloaded trunk from CVS that I could not find
> > a reference to dllwrap anywhere, nor Makefile.incl. Maybe this has
> > already been addressed?
>
>The build system for the upcoming 3.0.0 was changed to use autotools
>so libtool now handles this, hopefully.
>
>Boris
>
>--
>Boris Kolpackov
>Code Synthesis Tools CC
>http://www.codesynthesis.com
>Open-Source, Cross-Platform C++ XML Data Binding
Re: Makefile.incl under MINGW
Posted by Boris Kolpackov <bo...@codesynthesis.com>.
Hi David,
David Daeschler <da...@rsaisp.com> writes:
> The line that reads:
>
> MAKE_SHARED = dllwrap --export-all-symbols --driver-name ${CXX}
> ${LDFLAGS}
>
> can be changed to:
>
> MAKE_SHARED = ${CXX} -shared ${LDFLAGS}
>
> To avoid the bug in dllwrap.
If only you tested the release candidate and reported this a few days
ago, before the 2.8.0 release... Hopefully MINGW folks will fix the
bug in dllwrap.
One way to work around this without changing Makefile.incl is to build
Xerces-C++ as static library. For that add -s to the runConfigure
command line.
> I did notice that when I downloaded trunk from CVS that I could not find
> a reference to dllwrap anywhere, nor Makefile.incl. Maybe this has
> already been addressed?
The build system for the upcoming 3.0.0 was changed to use autotools
so libtool now handles this, hopefully.
Boris
--
Boris Kolpackov
Code Synthesis Tools CC
http://www.codesynthesis.com
Open-Source, Cross-Platform C++ XML Data Binding