1. 程式人生 > >Android原始碼編譯make的各類錯誤解決方案彙總

Android原始碼編譯make的各類錯誤解決方案彙總

問題: You are attempting to build with the incorrect version of java. 
Your version is: java version "1.6.0_22".
The correct version is: Java SE 1.6.
 
 
   查了一下現在已安裝的java:
  
  
  
   java -versionjava version "1.6.0_22"OpenJDK Runtime Environment (IcedTea6 1.10.4) (6b22-1.10.4-0ubuntu1~11.04.2)OpenJDK Client VM (build 20.0-b11, mixed mode, sharing)
   
  
 
解決辦法如下:
1.從java官方地址 http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase6-419409.html下載Java SE Development Kit 6 Update 45檔案。 2.移到/usr/lib/java目錄下執行 chmod a+x jdk-6u45-linux-amd64.bin 
sudo ./jdk-6u45-linux-amd64.bin        
新增環境變數:
sudo gedit /etc/profile 在檔案最後新增 #set java environment
export JAVA_HOME= /usr/lib/java/jdk1.6.0_45
export JRE_HOME= /usr/lib/java/jdk1.6.0_45/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
最後使環境變數生效:
source /etc/profile

Ubuntu系統預設安裝並使用OpenJDK(usr/lib/jvm/),因此需要手動修改系統預設的JDK,

sudo update-alternatives --install /usr/bin/javac javac /usr/lib/java/jdk1.6.0_45/bin/javac 300

sudo update-alternatives --install /usr/bin/java java /usr/lib/java/jdk1.6.0_45/bin/java 300

sudo update-alternatives --config javac,再選擇相應的Priority 300

sudo update-alternatives --config java,再選擇相應的Priority 300

至此配置完成,輸入java -version、javac或java檢查是否配置成功。


首先,我們先安裝一些常用的工具
curl: 
sudo  apt-get  install  curl

git: sudo  apt-get  install  git

g++: sudo  apt-get  install  g++

然後,遇到缺什麼就安裝什麼

/usr/bin/ld: cannot find -lz

host Executable: aapt (out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt)
/usr/bin/ld: cannot find -lz
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt] Error 1
解決方法: sudo apt-get install zlib1g-dev    sudo apt-get install lib64z1-dev

/bin/bash: bison: command not found

Yacc: aidl <= frameworks/base/tools/aidl/aidl_language_y.y
bison -d  -o out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp frameworks/base/tools/aidl/aidl_language_y.y
/bin/bash: bison: command not found
make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp] Error 127
解決方法:sudo apt-get install bison

/bin/bash: flex: command not found

out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp: In function ‘int yyparse()’:
out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp:1827: warning: deprecated conversion from string constant to ‘char*’
out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp:1970: warning: deprecated conversion from string constant to ‘char*’
Lex: aidl <= frameworks/base/tools/aidl/aidl_language_l.l
/bin/bash: flex: command not found
make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp] Error 127
解決方法: sudo apt-get install flex

/usr/bin/ld: cannot find -lncurses

host Executable: adb (out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb)
/usr/bin/ld: cannot find -lncurses
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb] Error 1

解決方法:sudo apt-get install libncurses5-dev或sudo apt-get install libncurses5-dev:i386

fatal error: GL/glx.h: No such file or directory

development/tools/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp:22: fatal error: GL/glx.h: No such file or directory
compilation terminated.
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libGLcommon_intermediates/GLDispatch.o] Error 1

解決方法:sudo apt-get install libgl1-mesa-dev

sh: gperf: not found

target Generated: libwebcore <= external/webkit/Source/JavaScriptCore/create_regex_tables
Generating CSSPropertyNames.h <= CSSPropertyNames.in
sh: gperf: not found
calling gperf failed: 32512 at ./makeprop.pl line 140.
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/css/CSSPropertyNames.h] Error 25
make: *** Deleting file `out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/css/CSSPropertyNames.h'

解決方法:sudo apt-get install gperf

編譯Android原始碼,按照installing-required-packages-ubuntu-1204提供方法先安裝必要的工具。

以下是編譯Android 4.0.3的常見錯誤,這些錯誤的解決辦法收錄自網際網路。

Google group有個專門的Android Building組,有興趣的可以加入。

有轉載這裡的也有新增的。

################# Fix 1 ##########################

Error:

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 make: *** [out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/AaptAssets.o] Error 1

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

Add '-fpermissive' to line 31:
LOCAL_CFLAGS += -Wno-format-y2k -fpermissive

################## Fix 2 ##########################

Error: frameworks/base/include/utils/KeyedVector.h:193:31: error: ‘indexOfKey’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive] frameworks/base/include/utils/KeyedVector.h:193:31: note: declarations in dependent base ‘android::KeyedVector<android::String8, android::wp<android::AssetManager::SharedZip> >’ are not found by unqualified lookup
frameworks/base/include/utils/KeyedVector.h:193:31: note: use ‘this->indexOfKey’ instead make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/AssetManager.o] Error 1

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

Add '-fpermissive' to line 64:
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) -fpermissive

################## Fix 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 ../..

################## Fix 3.1 ##########################

Error:
host C++: obbtool <= frameworks/base/tools/obbtool/Main.cpp
host C: parseStringTest <= external/srec/tools/parseStringTest/parseStringTest.c
<命令列>:0:0: 錯誤: “_FORTIFY_SOURCE”重定義 [-Werror]
frameworks/base/tools/obbtool/Main.cpp:1:0: 附註: 這是先前定義的位置
make: *** [out/host/linux-x86/obj/EXECUTABLES/obbtool_intermediates/Main.o] 錯誤 1

Fix: vi build/core/combo/HOST_linux-x86.mk    line56
Add  -U_FORTIFY_SOURCE HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0

################## Fix 4 ##########################

Error:
development/tools/emulator/opengl/host/tools/emugen/main.cpp:79:9: error: ‘optind’ was not declared in this scope
development/tools/emulator/opengl/host/tools/emugen/main.cpp:92:45: error: ‘optind’ was not declared in this scope
make: *** [out/host/linux-x86/obj/EXECUTABLES/emugen_intermediates/main.o] Error 1

Fix:
vi development/tools/emulator/opengl/host/tools/emugen/main.cpp

Add '#include <getopt.h>' to list of includes:
#include <getopt.h>

################## Fix 5 ##########################

Error:
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;

################## Fix 6 ##########################

Error:
development/tools/emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.cpp:345:65:   required from here
frameworks/base/include/utils/KeyedVector.h:193:31: error: ‘indexOfKey’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive] frameworks/base/include/utils/KeyedVector.h:193:31: note: declarations in dependent base ‘android::KeyedVector<unsigned int, ShaderData*>’ are not found by unqualified lookup
frameworks/base/include/utils/KeyedVector.h:193:31: note: use ‘this->indexOfKey’ instead make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libOpenglCodecCommon_intermediates/GLSharedGroup.o] Error 1

Fix:
vi development/tools/emulator/opengl/Android.mk

Add '-fpermissive' to line 25:
EMUGL_COMMON_CFLAGS := -DWITH_GLES2 -fpermissive

################## Fix 7 ##########################

Error:
/usr/bin/ld: note: 'XInitThreads' is defined in DSO /lib/libX11.so.6 so try adding it to the linker command line
/lib/libX11.so.6: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/emulator_renderer_intermediates/emulator_renderer] Error 1

Fix:
vi development/tools/emulator/opengl/host/renderer/Android.mk

Add new entry 'LOCAL_LDLIBS += -lX11' after line 6 as shown:
LOCAL_SRC_FILES := main.cpp
LOCAL_CFLAGS    += -O0 -g
LOCAL_LDLIBS += -lX11

#ifeq ($(HOST_OS),windows)
#LOCAL_LDLIBS += -lws2_32 

################## Fix 8 ##########################

Error:
external/llvm/include/llvm/ADT/PointerUnion.h:56:10: error: enumeral mismatch in conditional expression: ‘llvm::PointerLikeTypeTraits<llvm::PointerUnion<clang::Stmt*, const clang::Type*> >::<anonymous enum>’ vs ‘llvm::PointerLikeTypeTraits<clang::ObjCInterfaceDecl*>::<anonymous enum>’ [-Werror]
cc1plus: all warnings being treated as errors
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 

################## Fix 9 ##########################

Error:
frameworks/base/libs/rs/rsFont.cpp:224:76:   required from here
frameworks/base/include/utils/KeyedVector.h:193:31: error: ‘indexOfKey’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive] 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
frameworks/base/include/utils/KeyedVector.h:193:31: note: use ‘this->indexOfKey’ instead make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libRS_intermediates/rsFont.o] Error 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

################## Fix 10 #########################

Error:
external/mesa3d/src/glsl/linker.cpp:1394:49: error: expected primary-expression before ‘,’ token
......
external/mesa3d/src/glsl/linker.cpp:1734:59: error: ‘offsetof’ was not declared in this scope
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libMesa_intermediates/src/glsl/linker.o] Error 1

Fix:
vi external/mesa3d/src/glsl/linker.cpp

Add '#include <stddef.h>' to list of includes as shown: 
#include <climits>
#include <stddef.h>
#include <pixelflinger2/pixelflinger2_interface.h>

################## Fix 11 #########################

Error:
external/gtest/src/../include/gtest/gtest-param-test.h:287:58: note: ‘template<class Container> testing::internal::ParamGenerator<typename Container::value_type> testing::ValuesIn(const Container&)’ declared here, later in the translation unit
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libgtest_host_intermediates/gtest-all.o] Error 1

Two fixes required:
1)
vi external/gtest/src/Android.mk

Add '-fpermissive' to lines 52 and 70 (both lines contain same info)
LOCAL_CFLAGS += -O0 -fpermissive

2)
vi external/gtest/include/gtest/internal/gtest-param-util.h

Add '#include <stddef.h>' to list of includes as shown:
#include <vector>
#include <cstddef>
#include <gtest/internal/gtest-port.h>
################## Fix 12 ######################### 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


20150103補充:編譯sdk時遇到不少的問題

build/core/main.mk:670: *** Module 'AlarmProvider' in PRODUCT_PACKAGES has nothing to install!。

Indeed there is no a module with name AlarmProvider in the source tree now.
To fix it, remove AlarmProvider from the product definition in the following files:
./build/target/product/large_emu_hw.mk:25:    AlarmProvider
./build/target/product/generic_no_telephony.mk:24:    AlarmProvider

只去掉generic_no_telephony.mk就可以過,但是不過的東西太多了。
我想是main.mk中的判斷方法有誤,因為同樣一個檔案,編譯映象就可以過,編譯sdk就過不了。

在編譯原始碼的時候出現該錯誤

/usr/bin/ld.bfd.real: cannot find -lGL

/usr/bin/ld.bfd.real: cannot find -lX11

根據網上大多數的說法,以及官網的介紹。截至5月底,android對ubuntu12.04的編譯平臺的支援不是很推薦,有些庫的相容方面會有一些問題

這兩個錯誤報的錯其實就是說沒有在庫路徑中找到libGL.so libX11.so

但是開啟etc/ld.so.conf.d中檢視64位的庫路徑下x86_64-linux-gnu.conf配置檔案

# Multiarch support
/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu

該路徑下是有libGL.so的,並且檢視檔案連結指向沒有問題。但是編譯起來還是有錯。

後來再查看了一些資料,因為編譯的時候還是用到了32BIT的libGL.so libX11.so庫檔案,編譯的時候找的不是X86_64庫檔案配置,而是找的是I386庫檔案配置

# Multiarch support
/lib/i386-linux-gnu
/usr/lib/i386-linux-gnu
/lib/i686-linux-gnu
/usr/lib/i686-linux-gnu

果然在I386目錄下沒有找到這兩個檔案

首先安裝這兩個庫檔案的32位版本:

$ sudo apt-get install libx11-dev:i386(libX11.so)

$ sudo apt-get installibgl1-mesa-glx:i386(libGL.so)

由於libGL.so系統預設沒有進行庫路徑下的連結,還需要手動連結一下

$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1.2 /usr/lib/libGL.so


查詢指定的符號在Android.mk中

find ./ -name Android.mk -exec grep -l {} \;


環境要求改變。     現在要求記憶體1.5G左右,硬碟25G以上,以前1G、10G就夠了。官方說明“Note: The source download is approximately 6GB in size. You will need 25GB free to complete a single build, and up to 80GB (or more) for a full set of builds.”      可惜我編之前沒看,編譯報錯如下:    錯一: host SharedLib: libbcc (out/host/linux-x86/obj/lib/libbcc.so) collect2: ld terminated with signal 9 [Killed] make: *** [out/target/common/obj/JAVA_LIBRARIES/core_intermediates/noproguard.classes-with-local.dex] Killed make: *** Waiting for unfinished jobs…. make: *** [out/host/linux-x86/obj/EXECUTABLES/llvm-rs-cc_intermediates/llvm-rs-cc] Error 1 collect2: ld terminated with signal 9 [Killed] collect2: ld terminated with signal 9 [Killed] make: *** [out/host/linux-x86/obj/lib/libbcc.so] Error 1 make: *** [out/host/linux-x86/obj/EXECUTABLES/clang_intermediates/clang] Error 1 [email protected]:~/disk2/android-4.0.1_r1$ 錯二: target Dex: framework make: *** [out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/noproguard.classes-with-local.dex] Killed [email protected]:~/disk2/android-4.0.1_r1$ 錯三: arm-eabi-g++: Internal error: Killed (program cc1plus) 解決辦法: 這些錯誤都是 linux的OOM killer 導致,“記憶體1.5G左右,硬碟25G”就可以解決,我為了保險,把make -j4改成了make.編譯5個小時以上吧,out目錄大小:12G。
參考:
1.http://blog.csdn.net/mr_raptor/article/details/7394091
2.https://groups.google.com/forum/#!topic/android-building/kbhPdb6osms

收集和遇到的部分error,先記錄如下,改天按照建立android及使用情景分類整理。以後遇到的在慢慢新增進來

1.編譯錯誤:

/usr/bin/ldcannotfind -lz”

解決方法:

需要安裝zlib-dev這個包,線上安裝命令為:apt-getinstall zlib1g-dev

2.編譯錯誤:

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

解決方法:

$gedit frameworks/base/libs/utils/Android.mk

修改以下語句

LOCAL_CFLAGS+= -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS)

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

3.編譯錯誤:

arm-eabi-gcc:error trying to exec 'cc1': execvp: No such file or directory
make:*** [out/target/product/generic/obj/lib/crtbegin_dynamic.o] Error 1

解決方法:

如果之前的依賴包都已經安裝成功的話,此處應該是交叉編譯工具許可權的問題。這個問題只要在文章開頭lunch時執行了賦予許可權命令,就應該不會遇到了。

4.編譯錯誤:

<command-line>:0:0:error: "_FORTIFY_SOURCE" redefined [-Werror]
<built-in>:0:0: note: this is the location of the previousdefinition
cc1plus: all warnings being treated as errors
make:*** [out/host/linux-x86/obj/EXECUTABLES/obbtool_intermediates/Main.o]Error 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

5.編譯錯誤:

make:***[out/host/linux-x86/obj/EXECUTABLES/llvm-rs-cc_intermediates/slang_rs_export_foreach.o]錯誤1

解決辦法:

找到frameworks/compile/slang/slang_rs_export_foreach.cpp:249行,即:

llvm::StringRef ParamName = PVD->getName();

將本行註釋掉即可繼續編譯。


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

後來發現了,原來是Ubuntu11.10裡的gccg++版本太高了,於是執行下面的操作:

sudoapt-get install gcc-4.4

sudoapt-get install g++-4.4

sudorm -rf /usr/bin/gcc /usr/bin/g++

sudoln -s /usr/bin/gcc-4.4 /usr/bin/gcc

sudoln -s /usr/bin/g++-4.4 /usr/bin/g++

把預設的4.6版本換為了4.4,繼續編譯原始碼,又出現了另一個錯誤,大致提示為:

g++selected multilib '32' not installed

繼續奮戰吧,安裝相應的工具吧:sudoapt-get install g++-4.4-multilib,現在正在make-j8在我的i5/4G機子裡跑著。

make:***[out/host/linux-x86/obj/STATIC_LIBRARIES/libMesa_intermediates/src/glsl/linker.o]Error 1

解決這個問題需要修改檔案如下:

"#include<stddef.h>"新增到linker.cpp檔案頭部。

這樣就可以編譯完成了。

6.錯誤:

error:‘ptrdiff_t’ does not name a type
In file included fromexternal/gtest/src/../include/gtest/gtest-param-test.h:157:0,
                from external/gtest/src/../include/gtest/gtest.h:69,
                fromexternal/gtest/src/gtest_main.cc:32:
external/gtest/src/../include/gtest/internal/gtest-param-util.h:122:11:error: ‘ptrdiff_t’ does not name a type
In file included fromexternal/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,
                fromexternal/gtest/src/gtest-all.cc:36:
external/gtest/src/../include/gtest/internal/gtest-param-util.h:122:11:error: ‘ptrdiff_t’ does not name a type
In file included fromexternal/gtest/src/gtest-all.cc:38:0:
解決方法:
$viexternal/gtest/src/../include/gtest/internal/gtest-param-util.h
#include<cstddef>
7.錯誤:

undefinedreference to `pthread_mutexattr_destroy'
host C++: libgtest_host<= external/gtest/src/gtest-all.cc
true
host C++:libgtest_main_host <=external/gtest/src/gtest_main.cc
out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Signals.o):In function`PrintStackTrace':
/home/aa/project/android4.0.1/external/llvm/lib/Support/Unix/Signals.inc:219:undefined reference to`dladdr'
/home/aa/project/android4.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*,unsignedint)':
/home/aa/project/android4.0.1/external/llvm/lib/Support/Threading.cpp:96:undefined reference to`pthread_create'
/home/aa/project/android4.0.1/external/llvm/lib/Support/Threading.cpp:91:undefined reference to`pthread_attr_setstacksize'
/home/aa/project/android4.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/aa/project/android4.0.1/external/llvm/lib/Support/Mutex.cpp:69:undefined reference to`pthread_mutexattr_init'
/home/aa/project/android4.0.1/external/llvm/lib/Support/Mutex.cpp:75:undefined reference to`pthread_mutexattr_settype'
/home/aa/project/android4.0.1/external/llvm/lib/Support/Mutex.cpp:80:undefined reference to`pthread_mutexattr_setpshared'
/home/aa/project/android4.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/aa/project/android4.0.1/external/llvm/lib/Support/Mutex.cpp:143:undefined reference to `pthread_mutex_trylock'
collect2: ldreturned 1 exit status
make: ***[out/host/linux-x86/obj/EXECUTABLES/test-librsloader_intermediates/test-librsloader]Error 1
make: *** Waiting for unfinished jobs....
解決方法:
$viexternal/llvm/llvm-host-build.mk
LOCAL_LDLIBS := -lpthread-ldl
下面這個解決方法沒成功,會有新的錯誤:errorsagain :can't find threads.h file or dir.
$ viexternal/llvm/lib/Support/Android.mk
LOCAL_C_INCLUDES +=system/core/include/cutils
LOCAL_SHARED_LIBRARIES := libcutil
$vi external/llvm/lib/Support/Mutex.cpp
#include <threads.h>
$vi external/llvm/lib/Support/Threading.cpp
#include<threads.h>
8錯誤:

error:variable ‘ParamName’ set but not used[-Werror=unused-but-set-variable]
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 beingtreated 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

9.錯誤:

一、環境設定

[email protected]:~/Android/source$source build/envsetup.sh
includingdevice/htc/passion/vendorsetup.sh
includingdevice/samsung/crespo/vendorsetup.sh
[email protected]:~/Android/source$lunch full-eng

lunch時,如果提示permissiondenied許可權不夠的話,需要在原始碼根目錄下執行,賦予目錄下所有檔案許可權

[email protected]:~/Android/source$sudo chmod -R 777 *

這時候會lunch指令會打印出如下所示文段:

============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.3.3
TARGET_PRODUCT=full
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=GRI40
============================================

一、開始編譯

編譯過程可能會出現許多錯誤而中止,在此wayne將會把所有遇到的問題以及解決方法一一貼出來,以供以後參考。

10.錯誤:

[email protected]:~/Android/source$make-j2
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.3.3
TARGET_PRODUCT=full
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=GRI40
============================================
Checkingbuild tools versions...
build/core/main.mk:76:************************************************************
build/core/main.mk:77:You are attempting to build on a 32-bitsystem.
build/core/main.mk:78: Only 64-bit build environments aresupported beyond froyo/2.2.
build/core/main.mk:79:************************************************************
build/core/main.mk:80:*** stop
。停止。

解決方法:cd到原始碼根目錄,執行:

$gedit build/core/main.mk

找到

ifneq(64,$(findstring 64,$(build_arch)))

將其修改為

ifneq(i686,$(findstring i686,$(build_arch)))

相關推薦

Android原始碼編譯make各類錯誤解決方案彙總

問題: You are attempting to build with the incorrect version of java.  Your version is: java version "1.6.0_22". The corr

Android 原始碼編譯make錯誤處理

分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow 也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!        

Android 原始碼編譯aidl_language_l 相關錯誤解決

Android 原始碼編譯報錯: Lex: aidl <= frameworks/base/tools/aidl/aidl_language_l.l flex-2.5.39: loadlocale.c:130:_nl_intern_locale_data: ?? 'c

Android 原始碼編譯 make sdk ADT

下載eclipcse,如果不使用jee版本eclipse,在編譯ADT時會出現如下錯誤 6,配置環境變數 vim ~/.bashrc 在最後新增: ECLIPSE_HOME=/usr/lib/eclipse export ECLIPSE_HOME; export PATH=${PATH}:${ECLIPS

Android原始碼編譯時jdk衝突解決辦法

做Android rom開發過程中,可能會經常做不同的版本4.2,4.4,5.1或者6.0。每個版本的編譯環境對jdk的版本要求都有點差異。 4.2版本需要使用jdk1.5或者1.6,使用1.7的jdk編譯時會報型別錯誤等問題  5.1以上的版本需使用openJDK

Android原始碼編譯環境搭建問題及解決方案小結

1. ImportError: No module named bz2 for Python 2.7.2 (1)$ source build/envsetup.sh (2)$ lunch aosp_arm-eng (3)$ mak

android原始碼編譯錯誤解決

一定要看配置環境,如果缺少庫檔案或者環境不對,出的錯誤提示簡直各種各樣 以Ubuntu16.04編譯android8.1為例 sudo apt-get install libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-

Android Studio各類常見錯誤解決方案

(1)將Eclipse專案匯入到Android studio 中 很多點9圖出現問題解決方法: 在build.gradle裡新增以下兩句: aaptOptions.cruncherEnabled = false aaptOptions.useNewCrunche

zmap原始碼編譯安裝流程及錯誤解決方案

參考官方給出的方案在這裡,事實上針對ubuntu我們要進行一些調整。 注意:以下命令均進行在root許可權下 我的安裝環境:ubuntu12.04+zmap2.1.0 安裝依賴包 apt-

android原始碼編譯錯誤make ***[out/host/linux-x86/obj/EXECUTABL

     系統是Ubuntu1264位,2G記憶體,編譯的時候出現下面這個錯誤: make:***[out/host/linux-x86/obj/EXECUTABLES/llvm-rs-cc_intermediates/llvm-rs-cc]Error1make:***Waitingforunfinishe

android 報錯 This Gradle plugin requires a newer IDE able to request IDE model level 3 錯誤解決方案

轉載自: https://blog.csdn.net/JtooZC/article/details/79422323   android studio  匯入專案時報錯 This Gradle plugin requires a newer IDE able

uefi 編譯錯誤解決方案

沒有include 是 undefined unresolved 是 沒有link , 對應的define 沒有真正的實現 舉例: /Id:\project\edk2\CryptoPkg\Include  /Id:\project\edk2\CryptoPkg\Library\

Eclipse——編譯已有工程出現“ No rule to make target”的解決方案

【問題】:使用Eclipse開啟已有工程後,編譯出現如下錯誤“ No rule to make target”; 【原因】:          工程更改路徑或者更改了其中的資料夾名稱之後,之前生成的.o.d檔案在再次編譯時並不會

解決Android 原始碼編譯“audio_processing_impl”時,報錯“fatal error: list: No such file or directory”問題

我的系統是Linux Mint 17,使用的平臺是Tiny4412,編譯的是友善之臂提供的Android 4.2.2 原始碼。之前編譯沒有問題,今天編譯時,報出這個錯誤,查遍 百度/Google 都沒解決,後來發現是我之前手賤多配置了一個環境變數 NDK_ROOT 導致的問

Unity打安卓包 Android 所有錯誤解決方案大全(幾乎囊括所有打包錯誤 )

Unity打包出錯解決方案 本文提供全流程,中文翻譯。 Chinar 堅持將簡單的生活方式,帶給世人!(擁有更好的閱讀體驗 —— 高解析度使用者請根據需求調整網頁縮放比例) C

Android sdk 接入時遇到的錯誤解決方案

Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/mi/san/R$attr; Uncaught translation error: java.lang.

Android原始碼編譯命令m/mm/mmm/make分析

        在前文中,我們分析了Android編譯環境的初始化過程。android編譯環境初始化完成後,我們就可以用m/mm/mmm/make命令編譯原始碼了。當然,這要求每一個模組都有一個Android.mk檔案。Android.mk實際上是一個Makefile指令碼,用來描述模組編譯資訊。Andr

Android開發錯誤——Android Studio中遇到過的錯誤問題與解決方案彙總

(1)編譯時發生Error:(25, 0) Gradle DSL method not found: 'compile()' Possible causes:<ul><li>The project 'AP' may be using a version

ARM交叉編譯錯誤 cannot find crt1.o:錯誤解決方案

[cpp] view plaincopyprint?crt1.o: No such file or directory/opt/bin/../lib/gcc/arm-none-linux-gnueabi/4.7.2/../../../../arm-none-linux-gnu

【OpenCV入門教程之七】 玩轉OpenCV原始碼:生成OpenCV工程解決方案與OpenCV原始碼編譯

毛星雲,網路ID「淺墨」,90後,熱愛遊戲開發、遊戲引擎、計算機圖形、實時渲染等技術,就職於騰訊互娛。 微軟最有價值專家 著作《Windows遊戲程式設計之從零開始》、《OpenCV3程式設計入門》 碩士就讀於南京航空航天大學航天學院(2013級碩士研究生),已於2016年三月畢業。本科