Building Android on Snow Leopard
In a break from writing about my life, I thought I’d give some Android developers out there a hand with a problem. Google don’t yet support the building of Android on OS 10.6 (Snow Leopard), but I managed to get it working. To do this, you’ll need to do four things:
- Install Rosetta
- Install JDK 1.5
- Install OS 10.4 support for XCode
- Change some gcc headers
First, install Rosetta from your Snow Leopard installation DVD. This allows you to run flex from the command line. Without this, a file in libwebcore won’t be generated correctly and you’ll get an error about a missing lex() symbol.
Second, install JDK 1.5. I found a guide online to do this. Instead of using update 4 as mentioned in the article, download the 1.5 JDK update 5 from apple.com: http://support.apple.com/downloads/Java_for_Mac…. Update: after doing this, change the current SDK version by using the Java Preferences utility in Applications->Utilities.
Third, download the XCode 3 package from Apple and install support for building for the OS 10.4 target.
Finally, you need to add symlinks from some OS 10.4 gcc includes to the 10.6 ones. This is fairly easy to figure out when building, but the ones I changed were all in /Developer/SDKs/MacOSX10.4u.sdk/usr/include and are as follows:
- emmintrin.h -> /Developer/SDKs/MacOSX10.6.sdk/usr/lib/gcc/i686-apple-darwin10/4.2.1/include/emmintrin.h
- float.h -> /Developer/SDKs/MacOSX10.6.sdk/usr/lib/gcc/i686-apple-darwin10/4.2.1/include/float.h
- mm_malloc.h -> /Developer/SDKs/MacOSX10.6.sdk/usr/lib/gcc/i686-apple-darwin10/4.2.1/include/mm_malloc.h
- mmintrin.h -> /Developer/SDKs/MacOSX10.6.sdk/usr/lib/gcc/i686-apple-darwin10/4.2.1/include/mmintrin.h
- stdarg.h -> /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/stdarg.h
- xmmintrin.h -> /Developer/SDKs/MacOSX10.6.sdk/usr/lib/gcc/i686-apple-darwin10/4.2.1/include/xmmintrin.h
If you are building Android, then I am fairly certain I don’t need to tell you how to make symlinks.
Enjoy!
Update: in order to build the kernel, you’ll need to grab a copy of the elf.h header from Linux and copy it to /usr/local/include on your Mac. Comment out the #include <features.h>, otherwise you’ll get a compilation error.
Also, the following patches may be required on a 64 bit system: