2013年1月29日 星期二

[Android&Linux]在Ubuntu底下build出現error & 找不到庫lib

請依照版本 來配置build的環境  詳見:
官網[Initializing a Build Environment]

==============================================
2013/2/17更新
重灌後又重build發生:
install-info <- ava="" environment="" etc="" span="">

gcc: error trying to exec ‘cc1plus’: execvp: No such file or directory
使用:sudo apt-get install g++  (已驗證解決)

按照官網[Initializing a Build Environment] 打了卻出現

下列的套件有未滿足的相依關係:
 build-essential : 相依關係: dpkg-dev (>= 1.13.5) 但它卻將不會被安裝
 g++-multilib : 相依關係: gcc-multilib (>= 4:4.6.3-1ubuntu5) 但它卻將不會被安裝
                相依關係: g++-4.6-multilib (>= 4.6.3-1~) 但它卻將不會被安裝
E: 無法修正問題,您保留 (hold) 了損毀的套件。

網路查詢使用aptitude修復
所以我改用
sudo aptitude git-core gnupg flex bison gperf build-essential \ zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \ libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \ libgl1-mesa-dev g++-multilib mingw32 openjdk-6-jdk tofrodos \ python-markdown libxml2-utils xsltproc zlib1g-dev:i386$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

正在嘗試解決問題...
aptitude會嘗試將一些衝突的套件移除
之後再執行一次 官網的:

$ sudo apt-get install git gnupg flex bison gperf build-essential \
  zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \
  libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \
  libgl1-mesa-dev g++-multilib mingw32 openjdk-6-jdk tofrodos \
  python-markdown libxml2-utils xsltproc zlib1g-dev:i386
$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
目前build狀況還算順利...
感覺又突破了一點點

又出現找不到 -lz 用之前的方法 安裝zlib1g也沒用
找到網址:[android]找不到libz.so或libz.a文件  
/usr/bin/ld: cannot find -lzcollect2: ld returned 1 exit statusmake: *** [out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt] Error 1系统没有安装libz库,使用 apt-get install lib32z1-dev 安装。 
目前已經在build出android元件了 還算順利!!!

==================================================
==============================================


2013/1/30

索性部份mk描述內容 32 部份 64  結果出現

/usr/bin/ld: cannot find -lneo_cs   1002

之後 把目標鎖定在-lz問題裝了相關的包
zlib1g 跟zlib1g-dev 跟zlib1g-dbg 都給他 sudo apt-get install了

並把mk 都改回64


2013/2/3 重裝重build 更新 /bin/bash: bison:命令找不到部份:
flex 與 sh: 1: gperf: not found 
嚴重錯誤: bits/predefs.h:沒有此一檔案或目錄
編譯插斷
等問題 可以用底下的方案解決:

官網搜尋了一下資料可能是一些包沒裝好吧... 結果 打好之後 build
Installing required packages (Ubuntu 12.04)
Building on Ubuntu 12.04 is currently only experimentally supported and is not guaranteed to work on branches other than master.
$ sudo apt-get install git-core gnupg flex bison gperf build-essential \ zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \ libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \ libgl1-mesa-dev g++-multilib mingw32 openjdk-6-jdk tofrodos \ python-markdown libxml2-utils xsltproc zlib1g-dev:i386$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so



結果build過了

build完之後output會出現在檔案系統 > tmp > android > 裡面 千萬別傻傻的去build的源目錄裡面去找來複製

=====================================

2013/1/25

今天build android kernel 出現問題

make: *** [out/target/common/docs/api-stubs-timestamp] Error 45
make: *** Waiting for unfinished jobs....
make: *** [out/target/common/docs/doc-comment-check-timestamp] Error 45
類似這樣的錯誤訊息


網路人士分享解法:
google查得解决办法:
make clean
make update-api (经测试,这个可以不需要)sudo apt-get install g++
make


=============================================
原因釐清大概是因為我是64位元的作業系統,所以...
實際解法:(正在驗證...)

在 Android.mk 裡的 LOCAL_LDFLAGS += -m32 和 LOCAL_CFLAGS += -m32 由原本的 -m32 設定變更為 –m64 

modhd/android/external/clear silver/cs/Android.mk
modhd/android/external/clearsilver/util/Android.mk
modhd/android/external/clearsilver/cgi/Android.mk
modhd/android/external/clearsilver/java-jni/Android.mk

已解決解決方案在此
但是上述mk檔全改後變成出現
/usr/bin/ld: cannot find -lz             1002


Survey關鍵字cannot find -lXXX
找到解決方案:所有編譯過程中遇到類似錯誤,都是缺少libXXX之類的庫,解決方案是:
首先:利用命令:apt-cache search XXX 進行搜索
接著:找那些libXXX-dev之類的庫進行安裝,指令就是:sudo apt-get install libXXX-dev
最後:繼續make   若卡住還是類似的問題 就繼續搜尋+安裝新庫

================================================================
2013/1/23

又報錯

make: *** [/  ....................................................................] Error 1
make: *** Waiting for unfinished jobs....


上網爬了一下
/usr/bin/ld: cannot find -lxxx
这些讯息会随着编译不同类型的source code 而有不同的结果出来如:
  • /usr/bin/ld: cannot find -lc
  • /usr/bin/ld: cannot find -lltdl
  • /usr/bin/ld: cannot find -lXtst

其中xxx即表示函式库文件名称,如上例的:libc.so、libltdl.so、libXtst.so。其命名规则是:lib+库名(即xxx)+.so。

会发生这样的原因有以下三种情形:
2 相对应的lib版本不对
3 lib(.so档)的symbolic link 不正确,没有连结到正确的函式库文件(.so)
对于上述三种原因有一篇文章写的很棒可参考这一篇文章的第4点:
gcc命令祥解

解决方法:
(1)先判断在/usr/lib 下的相对应的函式库文件(.so) 的symbolic link 是否正确
若不正确改成正确的连结目标即可解决问题。
(2)若不是symbolic link 的问题引起,而是系统缺少相对应的lib安装lib即可解决。
(3)如何安装缺少的lib:
以上面三个错误讯息为例:
错误2缺少libltdl的LIB
错误3缺少libXtst的LIB 
 
  以Ubuntu为例:
  先搜寻相对应的LIB再进行安装的作业如:
apt-cache search libltdl-dev 
apt-cache search libXtst-dev
实例:
在进行输入法gcin的Source Code的编译时出现以下的错误讯息:
经检查后发现是:
lib(.so档)的symbolic link 不正确
解决方法如下:
ln -s libXtst.so.6 libXtst.so
如果在/usr/lib的目录下找不到libXtst.so 档,那么就表示系统没有安装libXtst的函式库。
解法如下:
1 系统没有安装相对应的lib
错误1缺少libc的LIB
  apt-cache search libc-dev
/usr/bin/ld: cannot find -lXtst
cd /usr/lib
apt-get install libxtst-dev


========================================2013/2/5 在網路上找到一個還蠻完整的解決方案 蒐錄進來
轉錄自http://www.linuxidc.com/Linux/2011-05/35891.htm


下面是我遇到的错误及解决方法:
/bin/bash: bison:找不到命令
Checking build tools versions…
************************************************************
You are attempting to build with the incorrect version
of java.
Your version is: /bin/bash: java:找不到命令.
The correct version is: 1.6.
Please follow the machine setup instructions at
http://source.android.com/source/download.html
************************************************************
build/core/main.mk:114: *** stop。 停止。
解决方法:
sudo apt-get install bison
———————————————————————-
Install: out/host/linux-x86/framework/droiddoc.jar
target Generated: libclearsilver-jni <= out/host/common/obj/JAVA_LIBRARIES/clearsilver_intermediates/javalib.jar
host C: libclearsilver-jni <= external/clearsilver/java-jni/j_neo_util.c
In file included from /usr/include/features.h:378,
from /usr/include/string.h:26,
from external/clearsilver/java-jni/j_neo_util.c:1:
/usr/include/gnu/stubs.h:9:27: error: gnu/stubs-64.h: 没有那个文件或目录
make: *** [out/host/linux-x86/obj/SHARED_LIBRARIES/libclearsilver-jni_intermediates/j_neo_util.o] 错误 1
解决方法:
sudo apt-get install libc6-dev-amd64
———————————————————————-
host SharedLib: libneo_util (out/host/linux-x86/obj/lib/libneo_util.so)
/usr/bin/ld: skipping incompatible /usr/lib/gcc/i486-linux-gnu/4.4.3/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/i486-linux-gnu/4.4.3/libstdc++.a when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/i486-linux-gnu/4.4.3/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/i486-linux-gnu/4.4.3/libstdc++.a when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/lib/libneo_util.so] 错误 1
解决方法:
sudo apt-get install g++-multilib
———————————————————————-
external/clearsilver/cgi/cgi.c:22:18: error: zlib.h: 没有那个文件或目录
external/clearsilver/cgi/cgi.c: In function ‘cgi_compress’:
external/clearsilver/cgi/cgi.c:885: error: ‘z_stream’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:885: error: (Each undeclared identifier is reported only once
external/clearsilver/cgi/cgi.c:885: error: for each function it appears in.)
external/clearsilver/cgi/cgi.c:885: error: expected ‘;’ before ‘stream’
external/clearsilver/cgi/cgi.c:888: error: ‘stream’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:888: error: ‘Bytef’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:888: error: expected expression before ‘)’ token
external/clearsilver/cgi/cgi.c:889: error: ‘uInt’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:889: error: expected ‘;’ before ‘str’
external/clearsilver/cgi/cgi.c:890: error: expected expression before ‘)’ token
external/clearsilver/cgi/cgi.c:892: error: ‘uLong’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:892: error: expected ‘)’ before ‘stream’
external/clearsilver/cgi/cgi.c:895: error: ‘alloc_func’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:895: error: expected ‘;’ before numeric constant
external/clearsilver/cgi/cgi.c:896: error: ‘free_func’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:896: error: expected ‘;’ before numeric constant
external/clearsilver/cgi/cgi.c:897: error: ‘voidpf’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:897: error: expected ‘;’ before numeric constant
external/clearsilver/cgi/cgi.c:900: error: ‘Z_DEFAULT_COMPRESSION’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:900: error: ‘Z_DEFLATED’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:900: error: ‘MAX_WBITS’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:900: error: ‘Z_DEFAULT_STRATEGY’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:901: error: ‘Z_OK’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:904: error: ‘Z_FINISH’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:905: error: ‘Z_STREAM_END’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c: In function ‘cgi_output’:
external/clearsilver/cgi/cgi.c:1200: error: ‘Z_NULL’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:1201: error: expected ‘)’ before ‘Bytef’
external/clearsilver/cgi/cgi.c:1201: warning: cast from pointer to integer of different size
external/clearsilver/cgi/cgi.c:1218: error: ‘Z_DEFLATED’ undeclared (first use in this function)
make: *** [out/host/linux-x86/obj/SHARED_LIBRARIES/libneo_cgi_intermediates/cgi.o] 错误 1
解决方法:
sudo apt-get install zlib1g-dev
———————————————————————-
host SharedLib: libneo_cgi (out/host/linux-x86/obj/lib/libneo_cgi.so)
/usr/bin/ld: skipping incompatible /usr/lib/gcc/i486-linux-gnu/4.4.3/../../../libz.so when searching for -lz
/usr/bin/ld: skipping incompatible /usr/lib/gcc/i486-linux-gnu/4.4.3/../../../libz.a when searching for -lz
/usr/bin/ld: skipping incompatible /usr/lib/libz.so when searching for -lz
/usr/bin/ld: skipping incompatible /usr/lib/libz.a when searching for -lz
/usr/bin/ld: cannot find -lz
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/lib/libneo_cgi.so] 错误 1
解决方法:
sudo apt-get install lib64z1-dev
———————————————————————-
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:找不到命令
make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp] 错误 127
解决方法:
sudo apt-get install flex
———————————————————————-
Docs droiddoc: out/target/common/docs/api-stubs
Could not load ‘clearsilver-jni’
java.library.path = out/host/linux-x86/lib
make: *** [out/target/common/docs/api-stubs-timestamp] 错误 45
解决方法:
安装 jdk1.5
———————————————————————-
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] 错误 1
解决方法:
sudo apt-get install libncurses5-dev
———————————————————————-
host C: emulator <= external/qemu/android/main.c
In file included from external/qemu/android/main.c:30:
prebuilt/linux-x86/sdl/include/SDL/SDL_syswm.h:55:22: error: X11/Xlib.h: 没有那个文件或目录
prebuilt/linux-x86/sdl/include/SDL/SDL_syswm.h:56:23: error: X11/Xatom.h: 没有那个文件或目录
In file included from external/qemu/android/main.c:30:
prebuilt/linux-x86/sdl/include/SDL/SDL_syswm.h:73: error: expected specifier-qualifier-list before ‘XEvent’
prebuilt/linux-x86/sdl/include/SDL/SDL_syswm.h:86: error: expected specifier-qualifier-list before ‘Display’
external/qemu/android/main.c: In function ‘main’:
external/qemu/android/main.c:1281: warning: implicit declaration of function ‘audio_check_backend_name’
make: *** [out/host/linux-x86/obj/EXECUTABLES/emulator_intermediates/android/main.o] 错误 1
解决方法:
sudo apt-get install libx11-dev
———————————————————————-
Generating CSSPropertyNames.h <= CSSPropertyNames.in
sh: gperf: not found
calling gperf failed: 32512 at ./makeprop.pl line 96.
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/css/CSSPropertyNames.h] 错误 25
make: *** 正在删除文件“out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/css/CSSPropertyNames.h”
解决方法:
sudo apt-get install gperf
Ubuntu10.04编译android1.5源码出错问题解决
环境:Ubuntu10.04     android1.5源码
make:
(1)/bin/bash: bison: command not found
解决:$ sudo apt-get install bison
(2)make: *** No rule to make target `Please-install-JDK-5.0,-update-12-or-higher,-which-you-can-download-from-java.sun.com’,
needed by `out/target/common/docs/api-stubs-timestamp’.  Stop.
解决:安装JDK 5.0
1):根据官方文档里所说,源代码的编译必须使用JDK5才能编译的了,所以这里我们使用jdk5
2): 需要先更新源,在终端里执行 sudo vim /etc/apt/sources.list
3): 在source.list里把以下2行拷贝到文档最后面:
deb http://us.archive.ubuntu.com/ubuntu/ jaunty multiverse
deb http://us.archive.ubuntu.com/ubuntu/ jaunty-updates multiverse
保存退出。
4): 执行 sudo apt-get update 更新源.
5): 配置编译环境并下载JDK5:sudo apt-get install sun-java5-jdk
(3)/bin /bash: g++: command not found
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libhost_intermediates/pseudolocalize.o] Error 127
解决:$ sudo apt-get install build-essential
(4)external/clearsilver/cgi /cgi.c:22:18: error: zlib.h: No such file or directory
external/clearsilver/cgi/cgi.c: In function ‘cgi_compress’:
external/clearsilver/cgi/cgi.c:885: error: ‘z_stream’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:885: error: (Each undeclared identifier is reported only once
external/clearsilver/cgi/cgi.c:885: error: for each function it appears in.)
external/clearsilver/cgi/cgi.c:885: error: expected ‘;’ before ‘stream’
external/clearsilver/cgi/cgi.c:888: error: ‘stream’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:888: error: ‘Bytef’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:888: error: expected expression before ‘)’ token
external/clearsilver/cgi/cgi.c:889: error: ‘uInt’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:889: error: expected ‘;’ before ‘str’
external/clearsilver/cgi/cgi.c:890: error: expected expression before ‘)’ token
external/clearsilver/cgi/cgi.c:892: error: ‘uLong’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:892: error: expected ‘)’ before ‘stream’
external/clearsilver/cgi/cgi.c:895: error: ‘alloc_func’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:895: error: expected ‘;’ before numeric constant
external/clearsilver/cgi/cgi.c:896: error: ‘free_func’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:896: error: expected ‘;’ before numeric constant
external/clearsilver/cgi/cgi.c:897: error: ‘voidpf’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:897: error: expected ‘;’ before numeric constant
external/clearsilver/cgi/cgi.c:900: error: ‘Z_DEFAULT_COMPRESSION’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:900: error: ‘Z_DEFLATED’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:900: error: ‘MAX_WBITS’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:900: error: ‘Z_DEFAULT_STRATEGY’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:901: error: ‘Z_OK’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:904: error: ‘Z_FINISH’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:905: error: ‘Z_STREAM_END’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c: In function ‘cgi_output’:
external/clearsilver/cgi/cgi.c:1200: error: ‘Z_NULL’ undeclared (first use in this function)
external/clearsilver/cgi/cgi.c:1201: error: expected ‘)’ before ‘Bytef’
external/clearsilver/cgi/cgi.c:1218: error: ‘Z_DEFLATED’ undeclared (first use in this function)
make: *** [out/host/linux-x86/obj/SHARED_LIBRARIES/libneo_cgi_intermediates/cgi.o] Error 1
解决:$ sudo apt-get install zlib1g-dev
(5)/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
(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
解 决:$ sudo apt-get install libncurses-dev
(7)prebuilt/linux-x86/sdl /include/SDL/SDL_syswm.h:55:22: error: X11/Xlib.h: No such file or directory
prebuilt/linux-x86/sdl/include/SDL/SDL_syswm.h:56:23: error: X11/Xatom.h: No such file or directory
In file included from external/qemu/android/skin/window.c:19:
prebuilt/linux-x86/sdl/include/SDL/SDL_syswm.h:73: error: expected specifier-qualifier-list before ‘XEvent’
prebuilt/linux-x86/sdl/include/SDL/SDL_syswm.h:86: error: expected specifier-qualifier-list before ‘Display’
make: *** [out/host/linux-x86/obj/EXECUTABLES/emulator_intermediates/android/skin/window.o] Error 1
解决:$ sudo apt-get install libx11-dev
(8)sh: gperf: not found
calling gperf failed: 32512 at ./makeprop.pl line 96.
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/css/CSSPropertyNames.h] Error 25
make: *** Deleting file `out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/css/CSSPropertyNames.h’
解 决:$ sudo apt-get install gperf
(9)frameworks/policies/base/PolicyConfig.mk:22: *** No module defined for the given PRODUCT_POLICY (android.policy_phone).  Stop.错误。
解决办法:
在build/tools/findleaves.sh中的第89行,
这一句find “${@:0:$nargs }” $findargs -type f -name “$filename” -print |
改为find “${@:1:$nargs-1 }” $findargs -type f -name “$filename” -print |
(10)frameworks/base/tools/aidl/AST.cpp:10: error: ‘fprintf’ was not declared in this scope的错误
解决办法:
下载gcc-4.3和g++-4.3
apt-get install gcc-4.3 g++-4.3
大约十多兆,然后
进入/usr/bin
cd /usr/bin
建个软连接
ln -s gcc-4.3 gcc
ln -s g++-4.3 g++


沒有留言:

張貼留言