Search code examples
cross-compilingxalanmingw32

Error while cross-compiling Xalan using mingw32


I am attempting to cross-compile Xalan for Windows using mingw32 on a Linux build host. I did this a year or so ago on Debian Lenny without too much trouble (just minor tweaks to the Makefile, and a native copy of MsgCreator), but trying to do it on Squeeze is turning out to be a bit more difficult.

The command that is failing is

i586-mingw32msvc-dllwrap --export-all-symbols --driver-name  \
  i586-mingw32msvc-g++ -mthreads -Wl,--allow-multiple-definition \
  ../../../../obj/XalanMsgLib.o -o ../../../../lib/libxalanMsg1_11_0.dll

Which is the command from the stock Makefile, with the the dllwrap command and driver-name corrected for my system (Debian Squeeze, mingw32 packages installed from the official repository)

The error produced is

../../../../obj/XalanMsgLib.o: In function `_ZN11xalanc_1_1117XalanMsgContainer10getMessageEj':
  XalanMsgLib.cpp:(.text+0x18): undefined reference to `_GLOBAL_OFFSET_TABLE_'
  ../../../../obj/XalanMsgLib.o: 
  .data.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]+0x0): 
  undefined reference to `__gxx_personality_v0'
  collect2: ld returned 1 exit status
  i586-mingw32msvc-dllwrap: i586-mingw32msvc-g++ exited with status 1

Following advice found here and on Google, I verified that (as far as I can tell) g++ is being used for linking, and that libstdc++ is being linked against (-lstdc++ is in LDFLAGS, and I've also manually specified it on the above command).

I've tried a few other things but so far nothing has worked, and I'm running out of ideas.

What's causing this error, and how can I fix it?


Solution

  • As it turns out, the advice I found about linking to libstdc++ was indeed correct and related, but the issue was occurring where I wasn't looking.

    The dllwrap command was passed -lstdc++, so that was fine, but the compilation of the object itself (XalanMsgLib.o) was not. This led to the unresolved symbol.

    Adding -lstdc++ to the Makefile that compiles the offending .o files (instead of only the final link step) resolved the issue.