Cross-compile 32bit on 64bit Linux


#1

Has anyone tried (and succeeded) compiling 32-bit JUCE on a 64-bit system?

I'm using a Mint17, 64-bit system and installed the multilib stuff, and it works fine for my own code.  But when I compile JUCE (with '-m32' in the CPPFLAGS) I get:


In file included from /usr/include/sys/select.h:30:0,
                 from /usr/include/sys/time.h:29,
                 from ../../JuceLibraryCode/modules/juce_core/native/juce_BasicNativeHeaders.h:170,
                 from ../../JuceLibraryCode/modules/juce_core/juce_core.cpp:43:
../../JuceLibraryCode/modules/juce_core/network/juce_Socket.cpp: In function ‘int juce::SocketHelpers::waitForReadiness(juce::SocketHandle, bool, int)’:
../../JuceLibraryCode/modules/juce_core/network/juce_Socket.cpp:148:9: error: inconsistent operand constraints in an ‘asm’
         FD_ZERO (&rset);

I assume it's some problem with my setup, but as I said, I've no problem compiling my other code for 32bit.

Any ideas?

Thanks


#2

Just stumbled on this...

I use a chroot environment to compile 32-bit versions on a 64-bit environment (Linux Mint 17).  It is basically a super-small (and super-raw) Debian system within your system.  You can find acomplete how-to in the manual for my plug-in K-Meter: https://github.com/mzuther/K-Meter/blob/master/doc/kmeter.pdf?raw=true

In short:

sudo apt-get install debootstrap schroot

sudo debootstrap --variant=buildd --arch i386 stable \
  /srv/chroot/stable_i386 http://ftp.de.debian.org/debian/

Add the following lines to /etc/schroot/schroot.conf and adapt the username:

[stable-i386]
description=Debian stable (i386)
directory=/srv/chroot/stable_i386
personality=linux32
root-users=username
type=directory
users=username

When debootstrap is done, log in as superuser by typing this on the console:

schroot -c stable-i386 -u root

You may then install all the packages you need.  Finally, log out (CTRL-D or command "exit") and log in as normal user:

schroot -c stable-i386

You should then be able to cross-compile your JUCE application.

As a side note, it does make sense to also compile your 64-bit applications in a chroot environment!  This way, you can easily spot problems that might be hidden on your development system because you may have installed many additional libraries or updated some by manual compilation...

Good luck!

Martin