MacOSX 编译Android 4.0的各种问题
2015-04-09 00:50
423 查看
之前编译过Android 4.2的源码,当时按照Android官方文档来的,并且系统环境与官方
要求基本相同,所以编译起来比较容易,可以参阅我之前的博客。
最近比较悲催的事情接二连三,有天晚上无意间删除了之前编译的4.0的源码,在MacOSX10.0.2上编译各种错误,发现应该和系统环境有关系,Xcode编译器和Android 4.0不匹配,然后切换不同的Xcode,更悲催的事情发生了,在更新比较旧的Xcode的时候,系统没有响应了,然后我硬关机了,结果系统挂掉了,无奈之下,卸掉磁盘,备份磁盘的内容,然后通过网络重新更新回10.10.2。联网更新不会抹掉系统的内容,一切都和之前的一样,好来想到之前编译4.0的时候用的是10.9.2系统,所以就利用U盘做了个10.9.2的Maverick,在格式化磁盘之前,用时间机器备份了10.10.2的系统。
开始10.9.2的编译之旅,发现10.9.2利用高版本的Xcode的时候,编译出错和10.10.2是一样的
以上错误主要是因为Xcode和Android 4.0不匹配导致的,5.0.2以上版本都会出现这个问题,当前最新的版本是Xcode 6.2,利用Xcode 4.6.3就可以解决这个问题。
将
在编译iptables的时候会缺少一些文件
或者参阅这里提供的代码
xt_MARK.h代码
xt_DSCP.h
解决办法
这个问题就是注释掉打印log。
这个问题,不知道是什么原因导致的,代码编译到这里进行不下去了,因为我只是想利用源码来编译应用程序,至此,已经可以利用mmm来编译应用程序了,留作以后解决吧,有知情的恰巧路过的高人,指点一下,留下只言片语吧。
在编译qemu时候,出现如下错误
没有搜索到相关信息,我注释掉register之后编译可以通过,但是会有类似上面的链接错误。
然后根据就注释掉和qemu相关的Android.mk内容,也就是没有编译相关代码,这个和emulator相关,我用不到,不过不编译确实说不过去。根据网上的一些信息,在这之前编译的sdk是4.6.3的10.9.sdk,然后安装10.5.sdk,但是还是出现这个链接错误,这个问题并没有解决。
修改./external/srec/srec/Recognizer/src/RecognizerImpl.c
vi frameworks/base/tools/aapt/Android.mk
LOCAL_CFLAGS += -Wno-format-y2k -fpermissive
貌似还有很多问题,这是事后总结的,忘了,以后坚持做的同时记录问题。
要求基本相同,所以编译起来比较容易,可以参阅我之前的博客。
最近比较悲催的事情接二连三,有天晚上无意间删除了之前编译的4.0的源码,在MacOSX10.0.2上编译各种错误,发现应该和系统环境有关系,Xcode编译器和Android 4.0不匹配,然后切换不同的Xcode,更悲催的事情发生了,在更新比较旧的Xcode的时候,系统没有响应了,然后我硬关机了,结果系统挂掉了,无奈之下,卸掉磁盘,备份磁盘的内容,然后通过网络重新更新回10.10.2。联网更新不会抹掉系统的内容,一切都和之前的一样,好来想到之前编译4.0的时候用的是10.9.2系统,所以就利用U盘做了个10.9.2的Maverick,在格式化磁盘之前,用时间机器备份了10.10.2的系统。
开始10.9.2的编译之旅,发现10.9.2利用高版本的Xcode的时候,编译出错和10.10.2是一样的
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/new:55: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/__config:192:20: error: typedef redefinition with different types ('char32_t' vs 'uint32_t' (aka 'unsigned int')) typedef __char32_t char32_t; ^ frameworks/base/include/utils/Unicode.h:25:18: note: previous definition is here typedef uint32_t char32_t;
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/type_traits:233:29: error: redefinition of 'std::__1::__is_integral<char16_t>' template <> struct __is_integral<unsigned short> : public true_type {}; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
以上错误主要是因为Xcode和Android 4.0不匹配导致的,5.0.2以上版本都会出现这个问题,当前最新的版本是Xcode 6.2,利用Xcode 4.6.3就可以解决这个问题。
frameworks/compile/slang/slang_rs_context.h:69:28: error: private field 'mTarget' is not used [-Werror,-Wunused-private-field] const clang::TargetInfo &mTarget;这个问题主要是将warning当做error来处理了,需要修改frameworks/compile/slang目录下的Android.mk
将
local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter -Werror修改为,也就是却掉-Werror
local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter
在编译iptables的时候会缺少一些文件
libxt_MARK.c:4:37: error: linux/netfilter/xt_MARK.h: No such file or directory
libxt_TOS.c:15:37: error: linux/netfilter/xt_DSCP.h: No such file or directory
libxt_connmark.c:26:41: error: linux/netfilter/xt_connmark.h: No such file or directory
libxt_rateest.c:9:40: error: linux/netfilter/xt_rateest.h: No such file or directory
libip6t_HL.c:9:42: error: linux/netfilter_ipv6/ip6t_HL.h: No such file or directory在external/iptables/include/linux目录下,添加缺少的文件,可以参阅http://git.oschina.net/androidsourcecode/external_iptables/tree/master/include/linux
或者参阅这里提供的代码
xt_MARK.h代码
#ifndef _XT_MARK_H_target #define _XT_MARK_H_target #include <linux/netfilter/xt_mark.h> #endif /*_XT_MARK_H_target */
xt_DSCP.h
/* x_tables module for setting the IPv4/IPv6 DSCP field * * (C) 2002 Harald Welte <laforge@gnumonks.org> * based on ipt_FTOS.c (C) 2000 by Matthew G. Marsh <mgm@paktronix.com> * This software is distributed under GNU GPL v2, 1991 * * See RFC2474 for a description of the DSCP field within the IP Header. * * xt_DSCP.h,v 1.7 2002/03/14 12:03:13 laforge Exp */ #ifndef _XT_DSCP_TARGET_H #define _XT_DSCP_TARGET_H #include <linux/netfilter/xt_dscp.h> #include <linux/types.h> /* target info */ struct xt_DSCP_info { __u8 dscp; }; struct xt_tos_target_info { __u8 tos_value; __u8 tos_mask; }; #endif /* _XT_DSCP_TARGET_H */
xt_connmark.h
#ifndef _XT_CONNMARK_H #define _XT_CONNMARK_H #include <linux/types.h> /* Copyright (C) 2002,2004 MARA Systems AB <http://www.marasystems.com> * by Henrik Nordstrom <hno@marasystems.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. */ enum { XT_CONNMARK_SET = 0, XT_CONNMARK_SAVE, XT_CONNMARK_RESTORE }; struct xt_connmark_tginfo1 { __u32 ctmark, ctmask, nfmask; __u8 mode; }; struct xt_connmark_mtinfo1 { __u32 mark, mask; __u8 invert; }; #endif /*_XT_CONNMARK_H*/
xt_rateest.h
#ifndef _XT_RATEEST_MATCH_H #define _XT_RATEEST_MATCH_H #include <linux/types.h> enum xt_rateest_match_flags { XT_RATEEST_MATCH_INVERT = 1<<0, XT_RATEEST_MATCH_ABS = 1<<1, XT_RATEEST_MATCH_REL = 1<<2, XT_RATEEST_MATCH_DELTA = 1<<3, XT_RATEEST_MATCH_BPS = 1<<4, XT_RATEEST_MATCH_PPS = 1<<5, }; enum xt_rateest_match_mode { XT_RATEEST_MATCH_NONE, XT_RATEEST_MATCH_EQ, XT_RATEEST_MATCH_LT, XT_RATEEST_MATCH_GT, }; struct xt_rateest_match_info { char name1[IFNAMSIZ]; char name2[IFNAMSIZ]; __u16 flags; __u16 mode; __u32 bps1; __u32 pps1; __u32 bps2; __u32 pps2; /* Used internally by the kernel */ struct xt_rateest *est1 __attribute__((aligned(8))); struct xt_rateest *est2 __attribute__((aligned(8))); }; #endif /* _XT_RATEEST_MATCH_H */
ip6t_HL.h
/* Hop Limit modification module for ip6tables * Maciej Soltysiak <solt@dns.toxicfilms.tv> * Based on HW's TTL module */ #ifndef _IP6T_HL_H #define _IP6T_HL_H #include <linux/types.h> enum { IP6T_HL_SET = 0, IP6T_HL_INC, IP6T_HL_DEC }; #define IP6T_HL_MAXMODE IP6T_HL_DEC struct ip6t_HL_info { __u8 mode; __u8 hop_limit; }; #endif
frameworks/compile/libbcc/lib/ExecutionEngine/SourceInfo.cpp:158:28: error: unused variable 'ec' [-Werror,-Wunused-variable] if (llvm::error_code ec = llvm::MemoryBuffer::getFile(file.path, MEM)) { ^这个问题和上面的Werror是一样的,修改frameworks/compile/libbcc目录下的libbcc-config.mk,
libbcc_CFLAGS := -Wall -Wno-unused-parameter -Werror去掉上面的-Werror即可。
Can't locate Switch.pm in @INC (@INC contains: /opt/local/lib/perl5/site_perl/5.16.3/darwin-thread-multi-2level /opt/local/lib/perl5/site_perl/5.16.3 /opt/local/lib/perl5/vendor_perl/5.16.3/darwin-thread-multi-2level /opt/local/lib/perl5/vendor_perl/5.16.3 /opt/local/lib/perl5/5.16.3/darwin-thread-multi-2level /opt/local/lib/perl5/5.16.3 /opt/local/lib/perl5/site_perl /opt/local/lib/perl5/vendor_perl/5.16.1/darwin-thread-multi-2level /opt/local/lib/perl5/vendor_perl/5.16.1 /opt/local/lib/perl5/vendor_perl .) at external/webkit/Source/WebCore/make-hash-tools.pl line 23. BEGIN failed--compilation aborted at external/webkit/Source/WebCore/make-hash-tools.pl line 23.
解决办法
sudo cpan -f Switch
frameworks/base/libs/rs/rsFifoSocket.cpp:73:26: error: invalid conversion specifier 'Z' [-Werror,-Wformat-invalid-specifier] LOGE("readReturn %p %Zu", data, bytes);
frameworks/base/libs/rs/rsFifoSocket.cpp:75:23: error: invalid conversion specifier 'Z' [-Werror,-Wformat-invalid-specifier] LOGE("readReturn %Zu", ret);
这个问题就是注释掉打印log。
host SharedLib: libext2_e2p_host (out/host/darwin-x86/obj/lib/libext2_e2p.dylib) Undefined symbols for architecture i386: "_ext2fs_get_generic_bitmap_end", referenced from: _ext2fs_get_block_bitmap_end in feature.o _ext2fs_get_inode_bitmap_end in feature.o "_ext2fs_get_generic_bitmap_start", referenced from: _ext2fs_get_block_bitmap_start in feature.o _ext2fs_get_inode_bitmap_start in feature.o "_ext2fs_mark_block_bitmap_range", referenced from: _ext2fs_fast_mark_block_bitmap_range in feature.o "_ext2fs_mark_generic_bitmap", referenced from: _ext2fs_mark_block_bitmap in feature.o _ext2fs_mark_inode_bitmap in feature.o _ext2fs_fast_mark_block_bitmap in feature.o _ext2fs_fast_mark_inode_bitmap in feature.o "_ext2fs_test_block_bitmap_range", referenced from: _ext2fs_fast_test_block_bitmap_range in feature.o "_ext2fs_test_generic_bitmap", referenced from: _ext2fs_test_block_bitmap in feature.o _ext2fs_test_inode_bitmap in feature.o _ext2fs_fast_test_block_bitmap in feature.o _ext2fs_fast_test_inode_bitmap in feature.o "_ext2fs_unmark_block_bitmap_range", referenced from: _ext2fs_fast_unmark_block_bitmap_range in feature.o "_ext2fs_unmark_generic_bitmap", referenced from: _ext2fs_unmark_block_bitmap in feature.o _ext2fs_unmark_inode_bitmap in feature.o _ext2fs_fast_unmark_block_bitmap in feature.o _ext2fs_fast_unmark_inode_bitmap in feature.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [out/host/darwin-x86/obj/lib/libext2_e2p.dylib] Error 1
这个问题,不知道是什么原因导致的,代码编译到这里进行不下去了,因为我只是想利用源码来编译应用程序,至此,已经可以利用mmm来编译应用程序了,留作以后解决吧,有知情的恰巧路过的高人,指点一下,留下只言片语吧。
在编译qemu时候,出现如下错误
In file included from external/qemu/memcheck/memcheck_util.h:22: external/qemu/target-arm/exec.h:22:30: error: global register variables are not supported register struct CPUARMState *env asm(AREG0);
没有搜索到相关信息,我注释掉register之后编译可以通过,但是会有类似上面的链接错误。
host Prebuilt: libSDLmain (out/host/darwin-x86/obj/STATIC_LIBRARIES/libSDLmain_intermediates/libSDLmain.a) host Executable: emulator-arm (out/host/darwin-x86/obj/EXECUTABLES/emulator-arm_intermediates/emulator-arm) Undefined symbols for architecture i386: "___bzero", referenced from: _audio_pcm_info_clear_buf in audio.o _gdbserver_start in gdbstub.o _qemu_main in vl-android.o _android_parse_options in cmdline-option.o _smc91c111_receive in smc91c111.o _smc91c111_writeb in smc91c111.o _bdrv_aio_multiwrite in block.o ... "_fdopen$DARWIN_EXTSN", referenced from: _qemu_fdopen in emulator-libqemu.a(savevm.o) "_fopen$DARWIN_EXTSN", referenced from: _parse_keyboard_layout in keymaps.o _load_image_targphys in loader.o _do_memory_save in monitor.o _do_physical_memory_save in monitor.o _rotate_qemu_log in vl-android.o _qemu_main in vl-android.o _SDL_main in main.o ... "_popen$DARWIN_EXTSN", referenced from: _qemu_popen_cmd in emulator-libqemu.a(savevm.o) _exec_start_outgoing_migration in emulator-libqemu.a(migration-exec.o) ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [out/host/darwin-x86/obj/EXECUTABLES/emulator-arm_intermediates/emulator-arm] Error 1
然后根据就注释掉和qemu相关的Android.mk内容,也就是没有编译相关代码,这个和emulator相关,我用不到,不过不编译确实说不过去。根据网上的一些信息,在这之前编译的sdk是4.6.3的10.9.sdk,然后安装10.5.sdk,但是还是出现这个链接错误,这个问题并没有解决。
host SharedLib: libSR_Recognizer (out/host/darwin-x86/obj/lib/libSR_Recognizer.dylib) Undefined symbols for architecture i386: "_pushAudioIntoRecognizer", referenced from: _SR_RecognizerAdvanceImpl in RecognizerImpl.o
修改./external/srec/srec/Recognizer/src/RecognizerImpl.c
replace all PINLINE with /*** PINLINE ***/ - actually remove all of them
</pre><pre name="code" class="plain">frameworks/base/include/utils/KeyedVector.h:193:31: note: declarations in dependent base ‘android::KeyedVector<android::String8, android::sp<AaptDir> >’ are not found by unqualified lookup frameworks/base/include/utils/KeyedVector.h:193:31: note: use ‘this->indexOfKey’ instead
vi frameworks/base/tools/aapt/Android.mk
LOCAL_CFLAGS += -Wno-format-y2k -fpermissive
Error: external/srec/tools/thirdparty/OpenFst/fst/lib/cache.h:136:11: note: use ‘this->SetState’ instead需要打patch
cd external/srec wget "https://github.com/CyanogenMod/android_external_srec/commit/4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff" patch -p1 < 4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff rm -f 4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff
貌似还有很多问题,这是事后总结的,忘了,以后坚持做的同时记录问题。
相关文章推荐
- Mac OS X 10.8.X编译Android4.2.X源码不生成emulator的问题
- MacOSX10.8编译Android4.0.1遇到的问题
- Mac OS X 10.8.X编译Android4.2.X源码不生成emulator的问题
- Mac OS X下搭建Android Source编译环境的问题及解决方法
- Mac OS X 10.8.3搭建Android工程源码的编译环境(解决找不到GCC、GIT、PYTHON的问题)
- Mac OS X 10.6下android源码编译
- 编译Android 4.0时遇到的问题汇总
- Mac OS X 10.8.3反编译Android apk
- android 4.0 编译模式 eng -- > user 时遇到的问题
- Android学习——Mac Os X下载和编译android 4.2.2 源码
- android 4.0 编译遇到的问题
- Mac OS X 编译android内核 error: elf.h: No such file or directory 的解决方法
- ubuntu64位编译android2.3源码遇到的各种问题解决方案
- Mac OS X 下部分Android手机无法连接adb问题之解决方案
- Mac OS X Lion 下编译Android 源码
- Mac OS X 下部分Android手机无法连接adb问题之解决方案
- Mac OS X配置android过程中遇到“R cannot be resolved to a variable”问题的解决
- ubuntu 11.10 编译android 4.0问题
- Mac OS X 下编译android源码
- 【转】Mac OS X下Android系统M2、华为部分手机无法连接问题之解决方案