2012年5月4日 星期五

Ubuntu 12.04 64Bit 版本編譯 Android ICS原始碼錯誤解決方法

升級Ubuntu 12.04 64位元版本後,在 編譯 Android 4.0.4 (ICS)  Source Code 時會報錯:
....(略).....
/usr/bin/ld: cannot find -lGL
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/lib/lib64EGL_translator.so] Errore 1
make: *** waiting for unfinished jobs

由於編譯時會使用到關於Open GL的函式庫,按照下列步驟執行可以解決解:
首先安裝libgl1-mesa-dev:i386 :
sudo apt-get install libgl1-mesa-dev:i386 <-- i386前有一個冒號,編譯時會使用到32bit Open GL函式庫

sudo ln -s /lib/i386-linux-gnu/libGL.so /lib/i386-linux-gnu/libGL.so.1
sudo cp -rf /usr/lib/i386-linux-gnu/mesa /usr/lib32

/usr/lib32/mesa編輯 ld.so.conf
cd  /usr/lib32/mesa
sudo vi ld.so.conf

/usr/lib/i386-linux-gnu/mesa
改成
/usr/lib32/mesa

接著繼續執行下列指令 :
sudo ldconfig
cd /usr/lib32
sudo ln -s mesa/libGL.so.1 libGL.so
ls -l /usr/lib32/libGL.so

確認 libGL.so 相關所在位置:
sudo find /usr/lib32 -name "libGL.so*"
最後執行:
sudo apt-get install libgl1-mesa-dev

繼續編譯後完成畫面:
PS:上圖中執行 lsb_release -a 只是為了證明在 Ubuntu 12.04 LTS 沒有其他意義。

如果編譯過程中有出現找不到 libGL.so.1 之類的訊息,請確認在 /usr/lib/i386-linux-gnu/mesa 目錄下有沒有下列函式庫:

-rw-r--r-- 1 root root         29 Mar 30 19:46 ld.so.conf
lrwxrwxrwx 1 root root      12 Mar 30 19:46 libGL.so.1 -> libGL.so.1.2
-rw-r--r-- 1 root root 358232 Mar 30 19:47 libGL.so.1.2


使用SDK模擬器執行編譯完成的image檔案:

cd mydroid/out/target/product/generic
emulator -image system.img -data userdata.img -ramdisk ramdisk.img

執行結果:

補充其他錯誤訊息解決方法:
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
make: *** Waiting for unfinished jobs....

build/core/combo/HOST_linux-x86.mk line 56:
-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
===========================================================

external/mesa3d/src/glsl/linker.cpp: In function ‘void assign_varying_locations(gl_shader_program*, gl_shader*, gl_shader*)’:
external/mesa3d/src/glsl/linker.cpp:1394:49: error: expected primary-expression before ‘,’ token
external/mesa3d/src/glsl/linker.cpp:1394:50: error: ‘varyings’ was not declared in this scope
external/mesa3d/src/glsl/linker.cpp:1394:58: error: ‘offsetof’ was not declared in this scope
external/mesa3d/src/glsl/linker.cpp:1395:48: error: expected primary-expression before ‘,’ token
external/mesa3d/src/glsl/linker.cpp:1412:47: error: expected primary-expression before ‘,’ token
external/mesa3d/src/glsl/linker.cpp:1412:48: error: ‘position’ was not declared in this scope
external/mesa3d/src/glsl/linker.cpp:1414:47: error: expected primary-expression before ‘,’ token
external/mesa3d/src/glsl/linker.cpp:1414:48: error: ‘pointSize’ was not declared in this scope
external/mesa3d/src/glsl/linker.cpp:1424:47: error: expected primary-expression before ‘,’ token
external/mesa3d/src/glsl/linker.cpp:1424:48: error: ‘position’ was not declared in this scope
external/mesa3d/src/glsl/linker.cpp:1428:47: error: expected primary-expression before ‘,’ token
external/mesa3d/src/glsl/linker.cpp:1428:48: error: ‘frontFacingPointCoord’ was not declared in this scope
external/mesa3d/src/glsl/linker.cpp:1431:47: error: expected primary-expression before ‘,’ token
external/mesa3d/src/glsl/linker.cpp:1431:48: error: ‘frontFacingPointCoord’ was not declared in this scope
external/mesa3d/src/glsl/linker.cpp: In function ‘void link_shaders(const gl_context*, gl_shader_program*)’:
external/mesa3d/src/glsl/linker.cpp:1734:49: error: expected primary-expression before ‘,’ token
external/mesa3d/src/glsl/linker.cpp:1734:50: error: ‘fragColor’ was not declared in this scope
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
make: *** Waiting for unfinished jobs....
mosquito@DG41MJ:~/mydroid$ 

Still an issue in 4.0.3_r1. Adding "#include <stddef.h> " to the very top of external/mesa3d/src/glsl/linker.cpp fixed it.

參考網站:http://code.google.com/p/android/issues/detail?id=23206
===========================================================

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
make: *** Waiting for unfinished jobs....
mosquito@DG41MJ:~/mydroid$ 

需要修改external/oprofile/libpp/format_output.h:94行
mutable counts_t & counts;改為
counts_t & counts;

參考網站:http://code.google.com/p/android/issues/detail?id=22003
===========================================================

....(略)....
external/gtest/src/../include/gtest/internal/gtest-param-util.h:122:11: error: ‘ptrdiff_t’ does not name a type
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libgtest_main_host_intermediates/gtest_main.o] Error 1
make: *** Waiting for unfinished jobs....
....(略)....

編輯 external/gtest/include/gtest/internal/gtest-param-util.h
 #include <vector> 
+#include <cstddef> 
 #include <gtest/internal/gtest-port.h>  
參考網站:http://code.google.com/p/android/issues/detail?id=22005
===========================================================

/home/mosquito/mydroid/external/llvm/lib/Support/Threading.cpp:96: undefined reference to `pthread_create'
/home/mosquito/mydroid/external/llvm/lib/Support/Threading.cpp:91: undefined reference to `pthread_attr_setstacksize'
/home/mosquito/mydroid/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/mosquito/mydroid/external/llvm/lib/Support/Mutex.cpp:69: undefined reference to `pthread_mutexattr_init'
/home/mosquito/mydroid/external/llvm/lib/Support/Mutex.cpp:75: undefined reference to `pthread_mutexattr_settype'
/home/mosquito/mydroid/external/llvm/lib/Support/Mutex.cpp:80: undefined reference to `pthread_mutexattr_setpshared'
/home/mosquito/mydroid/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/mosquito/mydroid/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....
mosquito@DG41MJ:~/mydroid$ 

解决方法:
$vi external/llvm/llvm-host-build.mk
LOCAL_LDLIBS := -lpthread -ldl

參考網站:http://code.google.com/p/android/issues/detail?id=22011
===========================================================

frameworks/compile/slang/slang_rs_export_foreach.cpp:249:23: error: variable ‘ParamName’ set but not used [-Werror=unused-but-set-variable]
cc1plus: all warnings being treated as errors
make: *** [out/host/linux-x86/obj/EXECUTABLES/llvm-rs-cc_intermediates/slang_rs_export_foreach.o] Error 1
make: *** Waiting for unfinished jobs....
mosquito@DG41MJ:~/mydroid$ 


解决方法:
$ 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
===========================================================

2 則留言:

  1. 這分享真棒!我最近才裝了 Ubuntu 12.04,改天也來試試。 ^^

    回覆刪除