在Mac OS X Lion 下编译Android 源码出现的一个问题

 

出错原因:

./external/elfutils/config-compat-darwin.h:42: error: static declaration of ‘strnlen’ follows non-static declaration

/usr/include/string.h:143: error: previous declaration of ‘strnlen’ was here

make: *** [out/host/darwin-x86/obj/STATIC_LIBRARIES/libelf_intermediates/lib/xmalloc.o] Error 1

 

解决方案:参考别人些的文章

http://blog.sephiroth.it/2011/10/17/compiling-android-source-on-mac-lion/

 

modify ./external/elfutils/config-compat-darwin.h.
replace:








static  inline  size_t strnlen  ( const  char  *__string ,  size_t __maxlen )
{
int len  =  0 ;
while  (__maxlen --  &&  *__string ++ )
len ++;
return len ;
}

with:









#if 0
static  inline  size_t strnlen  ( const  char  *__string ,  size_t __maxlen )
{
int len  =  0 ;
while  (__maxlen --  &&  *__string ++ )
len ++;
return len ;
}
#endif

Well, at the end of the process I just edited the Android.mk makefile into external/skia adding a new entry for BUILD_STATIC_LIBRARY and the next command was simply:


mmm external/skia

which produced the required libskia.a file to be linked in my project.

 

 

 

 

 

 

 

 

 

第二个问题:

warning: ignoring file out/host/darwin-x86/obj/STATIC_LIBRARIES/ 
libSDL_intermediates/libSDL.a, file was built for archive which is not 
the architecture being linked (i386) 
Undefined symbols for architecture i386: 

 

 

Do this by commenting out all lines in

external/qemu/Android.mk



The toolchain problem stems from the fact that Android actually supports the mac toolchain from Snow Leopard and onwards. So put homebrew path LAST in $PATH, so that it uses the Mac toolchain first.

When building DevNull/Oxygen ROM you in addition to the steps above also need to make a symlink in /usr/local/bin from sed to gsed, since they explicitly call gsed at one point. Also you have to disable WITH_DEXPREOPT like so:

make -j8 [devnull] WITH_DEXPREOPT=false

 

你可能感兴趣的:(Mac OS X)