28 August 2011

Compiling SDL on Lion

I ran into this problem while trying to compile Gingerbread on Lion, figuring that the existing SDL was a 64-bit library and Android wanted the 32-bit one. I grabbed the source from the SDL website and tried to compile using the -m32 flag in gcc, which resulted in several assembly errors. It turns out that this is a known incompatibility with llvm-gcc. [1] However, changing CC to gcc-4.2 wasn't good enough; ltmain.sh complains that it can't infer the tag configuration. [2]

Here is how I solved the problem: In build-scripts/makedep.sh, every time --mode=compile appears, put --tag=CC next to it. Then, in libtool, add a gcc-4.2 entry to the case statement in func_infer_tag() as follows:

case "$@ " in
  " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "* | "gcc-4.2"*)

It compiles! Install the library with sudo make install.

Unfortunately, the vanilla SDL and SDL used for the Android emulator aren't the same; besides the Android one being two releases earlier, I'm not too sure what the other differences are. The steps outlined above are not sufficient for building the SDL needed for the Android emulator. I'll report back if and when I get that working.

2 comments:

  1. still doesn't build for me with this hack.
    I get a :
    suffix or operands invalid for `movq'

    ReplyDelete