Pages

Monday, May 24, 2010

Slackware 13.0 x86_64 cross-compiling to 32-bit

I'm a programmer.

I like programming.

I want my computer with slackware 13.0 x86_64 to churn out 32-bit and 64-bit linux binaries; and I want to run wine.

I want to learn to compile to multiple targets using HaXe. Those targets are flash, android, php, javascript, C/C++/SDL (iPhone). So, download it; unpack it (tar xf); install it as root.

So the first thing I had to do was to refit my x86_64 compiler to cross-compile to 32-bit.

The first thing you find on the intarweb is this: http://connie.slackware.com/~alien/multilib/. Don't skim it. You'll thank me. Oh, you also owe a thanks to Eric Hameleers (aka AlienBob) and Fred Emmott (aka fred, of slamd64 fame). Go on irc.freenode.net and thank them. Thanks to them you can run wine on slackware 13.0 x86_64 and thus access win32 applications e.g. Flash Develop (note: must get .NET 2 to work on wine; used winetricks but failed horribly, removed some fonts, gave up, subject of another blogpost ).

Do everything described in the previous link.

When compiling with slackbuilds from slackbuild.org (SBo), you need for 32-bit applicationsto run on your machine. It would be wise to run the slackbuild like this from the shell as root:


$ ARCH=i686 sh gc.SlackBuild


ARCH=i686 will force the variable inside the slackbuild script to take on this value: "i686" which activates a few parameters for gcc to compile to this architecture, which is the canonical x86 architecture. By the way, my example "gc" is Boehm's garbage collector. It is required for neko to run properly.

Next thing, learn to use "ldd". Type `which ldd` to find your ldd binary, it checks whether the dependencies of a certain binary you're running can find the libraries they depend on.

You might find out that the slackbuild for gc on SBo fails, with the following message:


checking for C compiler default output file name...
configure: error: C compiler cannot create executables
See `config.log' for more details.


Fortunately, someone only forgot to put "-m32" in this line:

...
elif [ "$ARCH" = "i686" ]; then
SLKCFLAGS="-O2 -march=i686 -mtune=i686" # <-- this line!


So add it there.

SLKCFLAGS="-O2 -march=i686 -mtune=i686 -m32"


Run it again, then you're good to go!

Good luck.

No comments:

Post a Comment

Please help to keep this blog clean. Don't litter with spam.