Ubuntu 64位編譯 android 4.0源碼
以下錯誤是具體碰到,也有些是沒有碰到,網上查到的資料拷貝的備份;
===== 錯誤1 =====
host C++: obbtool <= frameworks/base/tools/obbtool/Main.cpp
:0:0: error: "_FORTIFY_SOURCE" redefined [-Werror]
: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
===== 錯誤2 =====
解決辦法:
build/core/combo/HOST_linux-x86.mk line 61:
把:
HOST_GLOBAL_CFLAGS += -D_FORTIFY_SOURCE=0
改為:
HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
參考:http://code.google.com/p/android/issues/detail?id=20795
===== 錯誤3 =====
development/tools/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp:22:20: 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
===== 錯誤4 =====
frameworks/compile/slang/slang_rs_export_foreach.cpp:247:23: error: variable ‘ParamName’ set but not used [-Werror=unused-but-set-variable]
解決辦法:
vim 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
參考:http://code.google.com/p/android/issues/detail?id=22006#c0
參考:http://groups.google.com/group/android-building/browse_thread/thread/0207abb98ed72304
===== 錯誤5 =====
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
解決辦法:
external/oprofile/libpp/format_output.h
把:
mutable counts_t & counts;
改為:
counts_t & counts;
===== 錯誤6 =====
external/llvm/lib/Support/Mutex.cpp:143: undefined reference to `pthread_mutex_trylock'
collect2: ld returned 1 exit status
解決辦法:
vim external/llvm/llvm-host-build.mk
LOCAL_LDLIBS := -lpthread -ldl
採用以下解決辦法沒有成功
vi external/llvm/lib/Support/Android.mk
添加
LOCAL_C_INCLUDES += system/core/include/cutils
LOCAL_SHARED_LIBRARIES := libcutil
(其中存在兩個模組,兩個都加上上面兩句話吧)
以及在Mutex.cpp檔案中加上threads.h標頭檔的引入
vi external/llvm/lib/Support/Mutex.cpp
添加
#include
以及在Threading.cpp檔案中加上threads.h標頭檔的引入
vi external/llvm/lib/Support/Threading.cpp
添加
#include
===== 錯誤7 =====
external/gtest/src/../include/gtest/internal/gtest-param-util.h:122:11: error: ‘ptrdiff_t’ does not name a type
解決辦法:
vim external/gtest/src/../include/gtest/internal/gtest-param-util.h
#include
===============
/usr/bin/ld: cannot find -lz
resolve:
1)缺少lib32z1-dev,安裝即可:apt-get install lib32z1-dev
lib64z1-dev =>64位
---------------------------------------------------------------------------
Ubuntu 11.04 下 Android4.0.1 編譯錯誤解決方案
分類: Android ubuntu 2011-12-13 14:46 3570人閱讀 評論(7) 收藏 舉報
1.錯誤一:error: ‘ptrdiff_t’ does not name a type
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/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 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:
external/gtest/src/../include/gtest/internal/gtest-param-util.h:122:11: error: ‘ptrdiff_t’ does not name a type
In file included from external/gtest/src/gtest-all.cc:38:0:
解決方案:
$vi external/gtest/src/../include/gtest/internal/gtest-param-util.h
#include <cstddef>
2.錯誤二: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
下面這個解決方案沒成功,會有新的錯誤:errors again :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>
3.錯誤三: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
這些錯誤有GCC4.6的,也有Android4.0的,在ubuntu和Android的官網上都有記載,可參看:
http://code.google.com/p/android/issues/detail?id=22011
http://code.google.com/p/android/issues/detail?id=22006#c0
http://groups.google.com/group/android-building/browse_thread/thread/0207abb98ed72304
https://wiki.edubuntu.org/GCC4.6
------------------------------------------------------------------------------
/usr/bin/ld: cannot find -lncurses
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb] Error 1
這個問題堵了我好幾天啊;因為我的系統是64位的;我:sudo apt-get install libncurses5-dev預設安裝的也是64位的;我不知道還需要各32位的;鬱悶;
解決:
sudo apt-get install lib32ncurses5-dev
------------------------------------------------------------------------------
ld+ld
:/:usr / bin/ld: cannot find -lstdc+cannot+cannot
findfind - -lstdccollect2: lstdc++++
collect2: collect2: ld returned 1 exit status
ld returned 1 exit status
ld returned 1 exit statusmake: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl] Error 1
解決:
sudo apt-get install gcc-multilib
sudo apt-get install g++-multilib
------------------------------------------------------------------------------
ubuntu12.04編譯omap核心錯誤總結:
2012/09/05/三
1:make menuconfig 出現很多undefined reference to'xxxxxxx'???
resolve:
sudo apt-get install libncurses5-dev
2:drivers/rtc/alarm.c:16:27: fatal error: asm/mach/time.h: No such file or directory
resolve:
arch/arm/include/asm/mach/time.h確實是存在的;但是就是有這個錯誤;
cp arch/arm/include/asm/time.h include/asm/mach/time.h
http://labs.beatcraft.com/en/index.php?Android%20for%20x86
3:sound/soc/soc-core.c:946:54: error: ‘ISA_DMA_THRESHOLD’ undeclared (first use in this function)
resolve:???????????
------------------------------
2012/09/06/四
------------------------------
**************************************************************************
*以上三個問題全部解決:sudo apt-get install gcc-arm-linux-gnueabi =>導致;*
*以上ubuntu12.04預設下載的交叉編譯器是4.6.3;版本太高,應該使用android源 *
*碼目錄~/prebuild/……/arm-eabi-4.4.3/……編譯器;
*
**************************************************************************
-------------------------------------------------------------------------------
2012/09/07/五
1:omap4boot 編譯註意:
a)只能用 sudo apt-get install gcc-arm-linux-gnueabi這個交叉編譯器才能變異通過;
------------------------------------------------------------------------------------