现在的位置: 首页 > 综合 > 正文

Android源码编译make的错误处理

2017年12月01日 ⁄ 综合 ⁄ 共 8072字 ⁄ 字号 评论关闭

Android源码下载:官方下载 或参考android源码下载方式

Android编译版本: PLATFORM_VERSION=4.0.1(注意该版本编译用的sdk是java1.6)

OS 操作系统平台: Linux Ubuntu  GNU/Linux(Ubuntu11.10 32bit)

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

git: sudo  apt-get  install  git

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

然后,make遇到缺什么就安装什么

=================错误1===================

/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

=================错误2===================

/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

=================错误3===================

/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

=================错误4===================

/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

=================错误5===================

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

=================错误6===================

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

 

=================错误7===================

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 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

 

=================错误8===================

 .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>

 

=================错误9===================

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
解决办法:
vim external/oprofile/libpp/format_output.h
把:
mutable counts_t & counts;
改为:
counts_t & counts;

=================错误10===================

undefined reference 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*, unsigned int)':
/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: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/test-librsloader_intermediates/test-librsloader] Error 1
make: *** Waiting for unfinished jobs....
解决方法:

$vi external/llvm/llvm-host-build.mk
LOCAL_LDLIBS := -lpthread -ldl

下面的方法无法解决错误,会出现新的错误:can't find threads.h file or dir$ vi external/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>

更多参考

抱歉!评论已关闭.