4

I am trying to compile static wxWidgets 3.1 Libraries for 32 bit Linux on a 64 bit Linux machine.

My configuration is the following:

../configure "CFLAGS=-m32" "CXXFLAGS=-m32" "LDFLAGS=-m32" --host=i686-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-shared --enable-unicode
make

The library starts to build but then halfway through I get this error:

In file included from /usr/lib64/glib-2.0/include/glibconfig.h:9:0,
             from /usr/include/glib-2.0/glib/gtypes.h:32,
             from /usr/include/glib-2.0/glib/galloca.h:32,
             from /usr/include/glib-2.0/glib.h:30,
             from /usr/include/glib-2.0/gobject/gbinding.h:28,
             from /usr/include/glib-2.0/glib-object.h:23,
             from /usr/include/glib-2.0/gio/gioenums.h:28,
             from /usr/include/glib-2.0/gio/giotypes.h:28,
             from /usr/include/glib-2.0/gio/gio.h:26,
             from /usr/include/gtk-2.0/gdk/gdkapplaunchcontext.h:30,
             from /usr/include/gtk-2.0/gdk/gdk.h:32,
             from /usr/include/gtk-2.0/gtk/gtk.h:32,
             from ../src/common/utilscmn.cpp:92:
/usr/include/glib-2.0/glib/gtypes.h: In function ‘gboolean 
_GLIB_CHECKED_ADD_U64(guint64*, guint64, guint64)’:
/usr/include/glib-2.0/glib/gmacros.h:142:29: error: size of array ‘_GStaticAssertCompileTimeAssertion_0’ is negative
   __attribute__((__unused__))
                         ^
/usr/include/glib-2.0/glib/gmacros.h:232:120: note: in expansion of 
macro ‘G_GNUC_UNUSED’
#define G_STATIC_ASSERT(expr) typedef char G_PASTE 
(_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] 
G_GNUC_UNUSED

^~~~~~~~~~~~~
/usr/include/glib-2.0/glib/gtypes.h:423:3: note: in expansion of macro 
‘G_STATIC_ASSERT’
   G_STATIC_ASSERT(sizeof (unsigned long long) == sizeof (guint64));
   ^~~~~~~~~~~~~~~
make: *** [Makefile:29632: corelib_utilscmn.o] Error 1

I notice that the error mentions glib and gtk-2.0. Am I missing a variant of these packages or is my configuration wrong? I believe that my configuration should be correct. Is there special wxWidgets specific options that I am missing in my configure?

Ripi2
  • 7,031
  • 1
  • 17
  • 33
nametable
  • 104
  • 8
  • Possible duplicate of [Build 32bit on 64 bit Linux using an automake configure script?](https://stackoverflow.com/questions/3261909/build-32bit-on-64-bit-linux-using-an-automake-configure-script) – liberforce Oct 20 '17 at 14:29
  • I think that answer is flawed. There must be some controversy on the difference between --host and --build. [What's the difference of `./configure` option `--build`, `--host` and `--target`?](https://stackoverflow.com/questions/5139403/whats-the-difference-of-configure-option-build-host-and-target) – nametable Oct 20 '17 at 15:10
  • You're right. That's the most voted answer to the 'possible duplicate' question that is wrong. – liberforce Oct 20 '17 at 15:39
  • OK, I've found the problem I think. `usr/lib64/glib-2.0/include/glibconfig.h` is being included instead of `/usr/lib/glib-2.0/include/glibconfig.h`. I have no idea why though. I made a link to the 32bit header and am not having an error anymore. I would think that configure would set the right headers though, right? – nametable Oct 20 '17 at 15:54
  • Yes, that's the whole point of cross compiling. Have you tried passing -m32 to CFLAGS and CPPFLAGS? CC and CXX are made for the compiler, not compiler flags, so maybe these don't get passed over. I don't think you need CC or CXX here, configure will detect the compiler it needs based on the host/build combination. – liberforce Oct 20 '17 at 15:57
  • Fore reference, details about how to call configure for cross compiling are here: http://gcc.gnu.org/onlinedocs/gccint/Configure-Terms.html – liberforce Oct 20 '17 at 15:59
  • Tried with `../configure "CFLAGS=-m32" "CXXFLAGS=-m32" "LDFLAGS=-m32" --host=i686-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-shared --enable-unicode`. Same error. – nametable Oct 20 '17 at 17:32
  • @Logan, in the last command can you switch `--host` and `--build`? – Igor Oct 20 '17 at 23:46
  • @Igor, when I swap `--host` and `--build` it compiles what seems to be 32 bit library binaries but stops midway with the same error. – nametable Oct 21 '17 at 00:43
  • @Logan, you could try to send an email to wx-dev ML. Or create a thread or wx forum before that. Just because wx forum has more people and you could get faster help there. – Igor Oct 21 '17 at 02:06

1 Answers1

0

After searching for the answer, it seems that the best method of cross compiling for 32 bit Linux on 64 bit Linux is to use a chroot build environment. This is apparently what many developers do.

There are some good instructions on Github.

nametable
  • 104
  • 8