Android系统源码学习——编译源码及编译过程中出现的错误

1、source build/envsetup.sh    # 设置编译环境

2、lunch   之后选择编译选项

3、执行make命令开始编译源码;

编译过程中出现的问题以及解决方案

错误1:

make: *** [out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/AaptAssets.o] 错误 1

Fix:

vi frameworks/base/tools/aapt/Android.mk

Add '-fpermissive' to line 31:

LOCAL_CFLAGS += -Wno-format-y2k –fpermissive

 

错误2:

make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/AssetManager.o] 错误 1

Fix:

vi frameworks/base/libs/utils/Android.mk

 

Add '-fpermissive' to line 64:

LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) –fpermissive

错误3:

Error:
external/srec/tools/thirdparty/OpenFst/fst/lib/cache.h:136:11: note: use ‘this->SetState’ instead
make: *** [out/host/linux-x86/obj/EXECUTABLES/grxmlcompile_intermediates/grxmlcompile.o] Error 1

Fix:
cd external/srec
wget "https://github.com/CyanogenMod/android_external_srec/commit/4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff"
patch -p1 < 4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff
rm -f 4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff
cd ../..

 

错误4:

make: *** [out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb] 错误 1

I think I found the answer by myself already.

$sudo apt-get install libncurses5-dev

This is working for me.U can try it!

解决方法:sudo apt-get install libncurses5-dev

错误5:

make: *** [out/host/linux-x86/obj/SHARED_LIBRARIES/libdvm_intermediates/native/dalvik_system_Zygote.o] Error 1make: *** Waiting for unfinished jobs....

所以,这个问题只能修改源代码来解决

在dalvik/vm/native/dalvik_system_Zygote.cpp中间增加一个头文件定义#include <sys/resource.h>

#include "Dalvik.h"

#include "native/InternalNativePriv.h"

#include <sys/resource.h>

错误6:

make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libext4_utils_intermediates/output_file.o] 错误 1

解决方案:

由于系统的文件换了位置, 此时需要将 /usr/include/x86_64-linux-gnu/zconfig.h 拷贝到上级目录,此时编译才通过将 zconfig.h 拷贝到 /usr/include/ 目录即可

错误7:

make: *** [out/host/linux-x86/obj/EXECUTABLES/obbtool_intermediates/Main.o] 错误 1

此处编译错误是由于ubuntu11.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

错误7:

make: *** [out/host/linux-x86/obj/EXECUTABLES/llvm-rs-cc_intermediates/slang_rs.o] Error 1

Fix:

vi frameworks/compile/slang/Android.mk

Remove '-Werror' from line 22:

local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter

错误8:

host StaticLib: librsloader (out/host/linux-x86/obj/STATIC_LIBRARIES/librsloader_intermediates/librsloader.a)

host C++: libLLVMJIT <= external/llvm/lib/ExecutionEngine/JIT/Intercept.cpp

external/llvm/lib/ExecutionEngine/JIT/Intercept.cpp: In constructor ‘{anonymous}::StatSymbols::StatSymbols()’:

external/llvm/lib/ExecutionEngine/JIT/Intercept.cpp:69:67: error: ‘lseek64’ was not declared in this scope

     sys::DynamicLibrary::AddSymbol("\x1lseek64", (void*)(intptr_t)lseek64);

make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMJIT_intermediates/Intercept.o] 错误 1

解决方案:

在external/llvm/lib/ExecutionEngine/JIT/Intercept.cpp中添加头文件

#define _LARGEFILE64_SOURCE

#include <stdlib.h>

#include <stdio.h>

#include <string.h>

#include <unistd.h>

#include <sys/types.h>

#include <sys/stat.h>

#include <fcntl.h>

#include <errno.h>

 

错误9:

BEGIN failed--compilation aborted at external/webkit/Source/WebCore/make-hash-tools.pl line 23.

make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/html/DocTypeStrings.cpp] 错误 2

解决方案:

解决方法:sudo apt-get install libswitch-perl

错误10:

host C++: liboprofile_pp <= external/oprofile/libpp/arrange_profiles.cpp

In file included from external/oprofile/libpp/arrange_profiles.cpp:24:0:

external/oprofile/libpp/format_output.h:94:22: error: reference ‘counts’ cannot be declared ‘mutable’ [-fpermissive]

make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/liboprofile_pp_intermediates/arrange_profiles.o] Error 1

解决方案:

Fix:

vi external/oprofile/libpp/format_output.h

Remove 'mutable' from 'mutable counts_t & counts;' on line 94:

counts_t & counts;

错误11:

make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libgtest_host_intermediates/gtest-all.o] 错误 1

解决方案:

gedit external/gtest/include/gtest/internal/gtest-param-util.h 添加:

#include <cstddef>

Error:

host Executable: test-librsloader (out/host/linux-x86/obj/EXECUTABLES/test-librsloader_intermediates/test-librsloader)

out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Signals.o):在函数‘PrintStackTrace’中:

/home/crow/works/Android_src/external/llvm/lib/Support/Unix/Signals.inc:219:对‘dladdr’未定义的引用

/home/crow/works/Android_src/external/llvm/lib/Support/Unix/Signals.inc:231:对‘dladdr’未定义的引用

out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Threading.o):在函数‘llvm::llvm_execute_on_thread(void (*)(void*), void*, unsigned int)’中:

/home/crow/works/Android_src/external/llvm/lib/Support/Threading.cpp:96:对‘pthread_create’未定义的引用

/home/crow/works/Android_src/external/llvm/lib/Support/Threading.cpp:100:对‘pthread_join’未定义的引用

/home/crow/works/Android_src/external/llvm/lib/Support/Threading.cpp:91:对‘pthread_attr_setstacksize’未定义的引用

out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Mutex.o):在函数‘llvm::sys::MutexImpl::MutexImpl(bool)’中:

/home/crow/works/Android_src/external/llvm/lib/Support/Mutex.cpp:69:对‘pthread_mutexattr_init’未定义的引用

/home/crow/works/Android_src/external/llvm/lib/Support/Mutex.cpp:75:对‘pthread_mutexattr_settype’未定义的引用

/home/crow/works/Android_src/external/llvm/lib/Support/Mutex.cpp:80:对‘pthread_mutexattr_setpshared’未定义的引用

/home/crow/works/Android_src/external/llvm/lib/Support/Mutex.cpp:89:对‘pthread_mutexattr_destroy’未定义的引用

out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Mutex.o):在函数‘llvm::sys::MutexImpl::tryacquire()’中:

/home/crow/works/Android_src/external/llvm/lib/Support/Mutex.cpp:143:对‘pthread_mutex_trylock’未定义的引用

collect2: 错误: ld 返回 1

make: *** [out/host/linux-x86/obj/EXECUTABLES/test-librsloader_intermediates/test-librsloader] 错误 1

Fix:

$vi external/llvm/llvm-host-build.mk

末尾加上:

LOCAL_LDLIBS := -lpthread -ldl

错误13:

frameworks/base/include/utils/KeyedVector.h:193:31: note: declarations in dependent base ‘android::KeyedVector<unsigned int, android::renderscript::Font::CachedGlyphInfo*>’ are not found by unqualified lookup

make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libRS_intermediates/rsFont.o] 错误 1

Fix:

vi frameworks/base/libs/rs/Android.mk

Add '-fpermissive' to line 183

LOCAL_CFLAGS += -Werror -Wall -Wno-unused-parameter -Wno-unused-variable -fpermissive

 

转载于:https://my.oschina.net/cht2000/blog/884005

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值