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

在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

 

1 楼 lbeing 2012-02-12  
你好,我在用lion时也遇到这个问题,

ignoring file out/host/darwin-x86/obj/STATIC_LIBRARIES/libSDL_intermediates/libSDL.a, file was built for archive which is not the architecture being
...
ake: *** [out/host/darwin-x86/obj/EXECUTABLES/emulator-arm_intermediates/emulator-arm] Error 1


对于你的第二步,还是没有看懂,能否说的详细点?
2 楼 dyf128 2012-02-25  
第二个问题 是第一个问题解决后我遇到的问题,导致编译不能继续了,貌似说external/qemu/Android.mk里面的内容清空,然后执行make -j8 [devnull] WITH_DEXPREOPT=false  但是我这样改了还是没通过 最终放弃了继续回到公司Linux上编译。