Re: Problem compiling with mingw

David McNab <[email protected]> Wed, 11 Feb 2009 18:00:28 +1300
Newsgroups gmane.comp.db.metakit
Message-ID <[email protected]>
On Tue, 2009-02-10 at 20:15 -0800, Ed Keith wrote:
> I am trying to build metakit with mingw on Windows XP, but it is not working.
> I get the following messages:

(irrelevant parts snipped)

> g++ -shared -o libmk4.so column.o custom.o derived.o fileio.o field.o format.o handler.o persi                                                               st.o remap.o std.o store.o string.o table.o univ.o view.o viewx.o 
> g++ -g -O2  -fPIC -DUSE_TCL_STUBS -I../unix/../include -I../unix/../src -I. -o demo.exe \
>         ../unix/../demos/demo.cpp libmk4.so 
> ../unix/../demos/demo.cpp:1: warning: -fPIC ignored for target (all code is position independe                                                               nt)
> libmk4.so:remap.cpp:(.text+0x0): multiple definition of `_onexit'
> /mingw/lib/crt2.o:crt1.c:(.text+0x10): first defined here
> libmk4.so:remap.cpp:(.text+0x30): multiple definition of `atexit'
> /mingw/lib/crt2.o:crt1.c:(.text+0x0): first defined here
> libmk4.so:remap.cpp:(.text+0x180): multiple definition of `__do_sjlj_init'
> C:/mingw/bin/../lib/gcc/mingw32/3.4.5/crtbegin.o:crtstuff.c:(.text+0x0): first defined here
> collect2: ld returned 1 exit status
> make: *** [demo] Error 1

I'm no metakit guru - just someone who has used it sometimes, but with
other software (not metakit) I've occasionally stumbled into similar
build problems to what you're suffering.

Problem, as you can see, is that the Metakit code includes redefinitions
of functions like '_onexit' and 'atexit', and '__do_sjlj_init', which
also appear in the standard libs.

Refer to the library link line:
        g++ -shared -o libmk4.so column.o custom.o derived.o fileio.o \
            field.o format.o handler.o persist.o remap.o std.o
        
Notice that 'remap.o' (which contains the duplicate symbols) occurs
fairly late in the link order. If the symbols get referenced by modules
earlier in the link order, mingw could be resolving those references
from the standard library without looking later in the list of link
modules.

This isn't a bug - I've seen it before with other compilers - but it can
be pretty damn annoying.

One workaround could be to edit the makefile and put remap.o first in
the library link list, so the command would then look like:

        g++ -shared -o libmk4.so remap.o column.o custom.o derived.o \ 
          fileio.o field.o format.o handler.o persist.o std.o

Hope this helps
Dave




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "metakit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/metakit?hl=en
-~----------~----~----~----~------~----~------~--~---