android源码:SEC_Android_Exynos4x12_TC4_ICS.dvt.01.ic.tar
这里编译环境已经搭建好,描述的是编译时遇到的问题:
1.
error:
============================================
Checking build tools versions...
************************************************************
You are attempting to build with the incorrect version
of java.
Your version is: java version "1.6.0_23".
The correct version is: Java SE 1.6.
Please follow the machine setup instructions at
http://source.android.com/source/download.html
************************************************************
解决方法1:
主要是由于 java 版本不对。
运行 sudo update-alternatives --config java 命令
配置一下 java 的版本,出再下面提示:
有 3 个候选项可用于替换 java (提供 /usr/bin/java)。
选择 路径 优先级 状态
------------------------------------------------------------
* 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 自动模式
1 /usr/lib/jvm/java-1.5.0-sun/jre/bin/java 53 手动模式
2 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 手动模式
3 /usr/lib/jvm/java-6-sun/jre/bin/java 63 手动模式
要维持当前值[*]请按回车键,或者键入选择的编号:3
这里选3就好了。
继续配置 jar 的版本。运行 sudo update-alternatives --config jar 命令
提示:
链接组 jar 中只有一个候选项:/usr/lib/jvm/java-6-sun/bin/jar
无需配置。
表明 jar 的版本 和 java 的版本一致,再继续编译就可以了
解决方法2:(这样会不会对编译结果产生影响)
由于ubuntu中可能会有默认的jdk,如openjdk,所以,为了使默认使用的是我们安装的jdk,还要进行如下工作。
执行
build/core/main.mk 中117行:ifneq ($(shell java -version 2>&1 | grep -i openjdk),)
改为:ifeq ($(shell java -version 2>&1 | grep -i openjdk),)
2.
error:
<command-line>:0:0: error: "_FORTIFY_SOURCE" redefined [-Werror]
<built-in>:0:0: note: this is the location of the previous definition
cc1plus: all warnings being treated as errors
make: *** [out/host/linux-x86/obj/EXECUTABLES/obbtool_intermediates/Main.o] Error 1
此处编译错误是由于ubuntu 11.10采用了GCC4.6.1导致的。
解决方法:
修改源码目录下/build/core/combo/HOST_linux-x86.mk文件:
将以下语句
HOST_GLOBAL_CFLAGS += -D_FORTIFY_SOURCE=0
修改为
HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
3.
error:
reference ‘counts’ cannot be declared ‘mutable’ [-fpermissive]
解决方法:external/oprofile/libpp/format_output.h
将 mutable counts_t & counts;
改为:
counts_t & counts;
4.
error:
.external/mesa3d/src/glsl/linker.cpp:623:33: 警告: ‘virtual ir_visitor_status remap_variables(ir_instruction*, gl_shader*,
hash_table*)::remap_visitor::visit(ir_dereference_variable*)’所隐藏 [-Woverloaded-virtual]
external/mesa3d/src/glsl/linker.cpp: 在函数‘void assign_varying_locations(gl_shader_program*, gl_shader*, gl_shader*)’中:
external/mesa3d/src/glsl/linker.cpp:1394:49: 错误: expected primary-expression before ‘,’ token
external/mesa3d/src/glsl/linker.cpp:1394:50: 错误: ‘varyings’在此作用域中尚未声明
external/mesa3d/src/glsl/linker.cpp:1394:58: 错误: ‘offsetof’在此作用域中尚未声明
external/mesa3d/src/glsl/linker.cpp:1395:48: 错误: expected primary-expression before ‘,’ token
external/mesa3d/src/glsl/linker.cpp:1412:47: 错误: expected primary-expression before ‘,’ token
external/mesa3d/src/glsl/linker.cpp:1412:48: 错误: ‘position’在此作用域中尚未声明
external/mesa3d/src/glsl/linker.cpp:1414:47: 错误: expected primary-expression before ‘,’ token
external/mesa3d/src/glsl/linker.cpp:1414:48: 错误: ‘pointSize’在此作用域中尚未声明
external/mesa3d/src/glsl/linker.cpp:1424:47: 错误: expected primary-expression before ‘,’ token
external/mesa3d/src/glsl/linker.cpp:1424:48: 错误: ‘position’在此作用域中尚未声明
external/mesa3d/src/glsl/linker.cpp:1428:47: 错误: expected primary-expression before ‘,’ token
external/mesa3d/src/glsl/linker.cpp:1428:48: 错误: ‘frontFacingPointCoord’在此作用域中尚未声明
external/mesa3d/src/glsl/linker.cpp:1431:47: 错误: expected primary-expression before ‘,’ token
external/mesa3d/src/glsl/linker.cpp:1431:48: 错误: ‘frontFacingPointCoord’在此作用域中尚未声明
external/mesa3d/src/glsl/linker.cpp: 在函数‘void link_shaders(const gl_context*, gl_shader_program*)’中:
external/mesa3d/src/glsl/linker.cpp:1734:49: 错误: expected primary-expression before ‘,’ token
external/mesa3d/src/glsl/linker.cpp:1734:50: 错误: ‘fragColor’在此作用域中尚未声明
external/mesa3d/src/glsl/linker.cpp:1734:59: 错误: ‘offsetof’在此作用域中尚未声明
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libMesa_intermediates/src/glsl/linker.o] 错误 1
解决方法:
vim external/mesa3d/src/glsl/linker.cpp
添加:
#include <cstddef>
5.
error:
.external/gtest/src/../include/gtest/internal/gtest-param-util.h:122:11: 错误: ‘ptrdiff_t’不是一个类型名
In file included from external/gtest/src/../include/gtest/gtest-param-test.h:157:0,
from external/gtest/src/../include/gtest/gtest.h:69,
from external/gtest/src/../src/gtest.cc:34,
from external/gtest/src/gtest-all.cc:36:
解决方法:
$vim external/gtest/src/../include/gtest/internal/gtest-param-util.h
#include <cstddef>
6.
error:
.host Executable: test-librsloader (out/host/linux-x86/obj/EXECUTABLES/test-librsloader_intermediates/test-librsloader)
host StaticLib: libui (out/host/linux-x86/obj/STATIC_LIBRARIES/libui_intermediates/libui.a)
out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Signals.o): In function `PrintStackTrace':
/home/shaocq/ics4.0.1/external/llvm/lib/Support/Unix/Signals.inc:219: undefined reference to `dladdr'
/home/shaocq/ics4.0.1/external/llvm/lib/Support/Unix/Signals.inc:231: undefined reference to `dladdr'
out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Threading.o): In function `llvm::llvm_execute_on_thread(void (*)
(void*), void*, unsigned int)':
/home/shaocq/ics4.0.1/external/llvm/lib/Support/Threading.cpp:96: undefined reference to `pthread_create'
/home/shaocq/ics4.0.1/external/llvm/lib/Support/Threading.cpp:91: undefined reference to `pthread_attr_setstacksize'
/home/shaocq/ics4.0.1/external/llvm/lib/Support/Threading.cpp:100: undefined reference to `pthread_join'
out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Mutex.o): In function `MutexImpl':
/home/shaocq/ics4.0.1/external/llvm/lib/Support/Mutex.cpp:69: undefined reference to `pthread_mutexattr_init'
/home/shaocq/ics4.0.1/external/llvm/lib/Support/Mutex.cpp:75: undefined reference to `pthread_mutexattr_settype'
/home/shaocq/ics4.0.1/external/llvm/lib/Support/Mutex.cpp:80: undefined reference to `pthread_mutexattr_setpshared'
/home/shaocq/ics4.0.1/external/llvm/lib/Support/Mutex.cpp:89: undefined reference to `pthread_mutexattr_destroy'
out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Mutex.o): In function `llvm::sys::MutexImpl::tryacquire()':
/home/shaocq/ics4.0.1/external/llvm/lib/Support/Mutex.cpp:143: undefined reference to `pthread_mutex_trylock'
collect2: ld 返回 1
make: *** [out/host/linux-x86/obj/EXECUTABLES/test-librsloader_intermediates/test-librsloader] 错误 1
make: *** 正在等待未完成的任务....
解决方法:
$vim external/llvm/llvm-host-build.mk
增加一行(不是开头或结尾都行):
LOCAL_LDLIBS := -lpthread -ldl
7.
error:
frameworks/compile/slang/slang_rs_export_foreach.cpp:247:23: error: variable ‘ParamName’ set but not used [-Werror=unused-but-set-variable]
cc1plus: all warnings being treated as errors
解决方法:
$ vi frameworks/compile/slang/Android.mk
将:
local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter -Werror
改为:
local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter
还有一个尚未遇到的出错,但是其他人有标注:
frameworks/base/libs/utils/RefBase.cpp:483:67: error: passing ‘const android::RefBase::weakref_impl’ as ‘this’ argument of ‘void android::RefBase::weakref_impl::trackMe(bool, bool)’ discards qualifiers [-fpermissive] make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/RefBase.o] Error 1
解决方法:vim frameworks/base/libs/utils/Android.mk
修改以下语句
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS)
为
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) -fpermissive
编译成功后,在TC4_ICS/out/target/product/smdk4x12/有三个文件ramdisk.img, system.img, userdata.img
最后,打包时遇到的错误
make otapackage
出现的错误:
Could not create the Java virtual machine.
ERROR: signapk.jar failed: return code 1
可能是由于虚拟机空间不够需要修改小些修改build/tools/releasetools/common.py文件
cmd = ["java", "-Xmx2048m", "-jar",
os.path.join(OPTIONS.search_path, "framework", "signapk.jar")]
其中的-Xmx2048m 改为-Xmx1024m