程式設計物語 Programming Story

/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] Error 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] Error 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] Error 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] Error 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] Error 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] Error 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] Error 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] Error 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] Error 25
make: *** 正在删除文件“out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/css/CSSPropertyNames.h”

解决方法:
sudo apt-get install gperf

android中c/c++程序的調試(eclipse)

1. 使用gdbserver調試
使用JDWP只能調試java層面的程序,如果想調試C層面的代碼,需要使用gdbserver方式,gdbserver的服務端和客戶端都包含在android的源碼中。
server端是out/target/product/xxxxxx/system/bin/gdbserver。
client端是prebuild/linux-x86/toolchain/xxxxxx/bin/arm-eabi-gdb),不需另外安裝。
(請看完本文再開始調試,尤其是“注意”部分)

2. 調試前的准備:編譯DEBUG版本的程序和庫
1) 新建(或修改)ANDROID源碼根目錄的buildspec.mk,加入以下內容
DEBUG_MODULE_lidvm:=true # 虛擬機模塊設為debug
TARGET_CUSTOM_DEBUG_CFLAGS:=-O0 -mlong-calls
(請修改具體模塊名,我調試的是虛擬機的libdvm.so庫)
2) 重編dalvik模塊
$ make clean-libdvm
$ make dalvik snod
3) 重燒system.img或替換手機中的相應模塊

3. gdb server端配置
1) 端口映射
$ adb forward tcp:5039 tcp:5039 把設備的5039端口映射到PC的5039
設定之後用netstat -na命令可看到PC的5039端口已處於listen狀態
注意每次斷開手機再連接時,都要重新執行該命令
2) 調試進程號為2014進程
$ adb shell
# ps 找進程號
# gdbserver :5039 –attach 2014 # 指明tcp端口號和進程號
注意:用此方法只適用於對已運行的程序debug(不能使用直接在gdbserver後跟程序名的方式運行)
此時2014進程被掛起,等待調試

4. gdb client端配置
1) 用命令行工具調試
$ $ANDROID_DIR/prebuilt/linux-x86/toolchain/xxxxxx/bin/arm-eabi-gdb $ANDROID_DIR/out/target/product/xxxxxx/system/bin/app_process
注意可執行程序名必須是app_process,不是你所調試的程序名
(gdb) set solib-absolute-prefix $ANDROID_SRC)/out/target/product/xxxxxx/symbols/system/lib/
(gdb) set solib-search-path $ANDROID_SRC)/out/target/product/xxxxxx/symbols/system/lib/
以上路徑為GDB默認庫的搜索路徑,即交叉編譯器庫路徑,若不設定,則找不到符號表,(帶符號表的庫在symbols/system/lib/*,手機裡strip後無符號表的庫在system/lib/*,它們必須配套使用)
(gdb) target remote :5039 指明TCP端口號
此時連接gdb server,可設斷點調試,按c繼續執行程序
2) 用eclipse調試
a) 安裝cdt,使eclipse支持c/c++程序的開發
i. 下載
從http://www.eclipse.org/cdt/downloads.php下載cdt-master-4.0.0.zip
ii. 解壓
$ mkdir cdt; cd cdt; unzip ../cdt-master-4.0.0.zip
iii. 將解壓縮後的features、plugins兩個文件夾的內容復制到Eclipse安裝目錄中
$ cp plugins/* ../../eclipse/plugins/
$ cp features/* ../../eclipse/features/
iv. 重新開啟Eclipse即可
$ eclipse -clean
在新建project中即可看到c/c++相關選項,說明已安裝成功
b) 加入要調試的代碼
i. 新建C++ project (菜單File->New->Project…)
不使用default location,把Location指定成代碼所在目錄
ii. 取消自動編譯選項(菜單Project->Build Automatically)
c) 配置gdb環境
配置Debug Configurations(菜單Run->Debug Configurations…)
i. 新建一個C/C++ Local Application的debug configuration
ii. Main選項卡中
指定Project為新建的C++工程,
C/C++ Applications為:
$ANDROID_DIR/out/target/product/xxxxxx/system/bin/app_process
iii. Debugger選項卡中
指定Debugger為gdbserver Debugger,
Main子選項卡的Gdb debuger設為:
$ANDROID_DIR/prebuilt/linux-x86/toolchain/xxxxxx/bin/arm-eabi-gdb
GDB command file設為一個文件名,文件內容如下:
file $ANDROID_DIR/out/target/product/xxxxxx/system/bin/app_process
set solib-absolute-prefix $ANDROID_SRC)/out/target/product/xxxxxx/symbols/system/lib/
set solib-search-path $ANDROID_SRC)/out/target/product/xxxxxx/symbols/system/lib/
Connection子選項卡:
Type設為TCP,Port number設為5039
iv. 點擊Debug按鈕進入調試,之前掛起的程序此時繼續運行
d) 設置斷點及調試
i. 找開某一C程序(菜單->Open file)
ii. 在程序中雙擊可設置斷點,設置後斷點出現在右上的Breakpoints中
iii. Debug選項卡提供了工具調試(suspend, resume等)

5. 加打印語句
如果需要在C程序中加打印語句,有兩種方法
1) 直接在代碼中使用printf,此方法只能應用於從命令行啟動程序的情況,運行時可以adb shell中看到打印信息
2) 使用程序中提供的重定項後的打印語句,並在logcat中看到它
例如在libdvm.so中使用dvmFprintf(stderr, “xieyan log\n”);
6. 可能出現的問題及解決方法
1) 在找不到原因時,可以寫一個在android可以運行的簡單c語言程序用gdbserver調試,以簡化問題,android中c程序做法見:
http://www.top-e.org/jiaoshi/html/?157.html
2) 我的是在arm-eabi-2.4.1的編譯器編出來的,你的可能不是,編譯時用make showcommands 確定你的系統使用的編譯工具鏈,否則如果你debug時用的和編譯時用的版本不一致,會導致讀符號表時出錯(注意看提示)
3) 有時編譯會引起源碼目錄的變化,請在左側Project explorer中刷新相關項目

問題
剛裝好UBUNTU後
急著想利用"軟體中心"裝軟體,結果就出現以下訊息,然後安裝程序就卡住了
waiting for jockey-backend exit

怎麼辦?

解答:
這是因為安裝好UBUNTU時候,會更新軟體一段時間,更新程式占用了jockey
   理論上等一段時間就好了,不過不想等的話,可利用以下指令

ps -e | grep jockey
系統會顯示一組執行程序號碼、比方說113之類
然後在終端機中輸入
sudo kill 上述號碼 (sudo kill 113)
即可

仍然記得裝好後要重開機,讓ubuntu繼續該有的update啊

無法用git下載Android source
錯誤訊息
dream@pcsw-s1:~/bin$ ./repo init -u git://gitorious.org/rowboat/manifest.git -m ManifestName
Getting repo …
   from git://Android.git.kernel.org/repo.git
fatal: Unable to look up Android.git.kernel.org (port 9418) (Name or service not known)

怎麼辦?

<!–[if gte mso 10]>

table.MsoNormalTable
{
font-size:12.0pt;
font-family:"sans-serif";
}
</style>
–>

步驟:
1.
下載repo-1.12 (下載連結)  (不放心的話請自行google "repo 1.12" XD)
2.
更名
$ mv repo-1.12 repo
3.
增加執行許可權
$ chmod a+x repo
4.
拷貝到/user/bin目錄
$ sudo cp repo /user/bin
完工
5.
如果repo init時出現 https 443 ssl錯誤,那麼需要將https更改為http
$ sudo vi /user/bin/repo
將第五行
REPO_URL='https://code.google.com/p/git-repo/'
改為
REPO_URL='http://code.google.com/p/git-repo/'

要下載Android,輸入指令
    repo init -u git://android.git.kernel.org/platform/manifest.git

預期結果是要去找各分支、並且要問我帳號那些,但結果卻出現以下錯誤訊息
Getting repo …
   from git://android.git.kernel.org/tools/repo.git
android.git.kernel.org[0: 130.239.17.13]: errno=Connection refused
android.git.kernel.org[0: 149.20.4.77]: errno=No route to host
android.git.kernel.org[0: 199.6.1.173]: errno=Connection refused
android.git.kernel.org[0: 2001:6b0:e:4017:1972:112:1:0]: errno=Network is unreachable
android.git.kernel.org[0: 2001:4f8:1:10:1972:112:1:0]: errno=Network is unreachable
android.git.kernel.org[0: 2001:4f8:8:10:1972:112:1:0]: errno=Network is unreachable
android.git.kernel.org[0: 2001:500:60:10:1972:112:1:0]: errno=Network is unreachable
fatal: unable to connect a socket (Network is unreachable)

該怎麼辦呢?

-------------------------------------------
解答:
這是因為kernel.org網站被hack關係,你可以去http://android.git.kernel.org看

結果會出現一隻綿羊還有奇怪的訊息
    Nothing to see here – only dreams of electric sheep

解決方式:
1.修改 家目錄下的repo
  vi ~/bin/repo

  將
    REPO_URL='git://android.git.kernel.org/tools/repo.git'
 改成
    REPO_URL='http://android.git.kernel.org/tools/repo.git&#039;

2.指令改下
 repo init -u http://android.git.kernel.org/platform/manifest.git -b gingerbread
 (Dream: 沒有-b應該也可以)

3.修改Android目錄下的.repo/manifests/default.xml
    vi .repo/manifests/default.xml
 將    
 fetch="git://android.git.kernel.org/"
 改成
 fetch="http://android.git.kernel.org/&quot;

4.repo sync
 成功!

問題描述:

為了讓BCB使用其他C++編譯器產生的DLL檔案,首先使用靜態調度DLL的方式,方法為產生BCB需要的Lib檔案(使用implib MainAlgorithm.lib MainAlgorithm.dll 來產生)

包入*.lib後,在檔案開頭用
extern "C" __declspec(dllimport) int  SearchSolution(char* info);

宣告…

結果:當我們執行 迴圈:  while(SearchSolution(info)){….}  時候,且執行的東西夠大,立刻就會產生Overflow!!該怎麼解決呢?

這個問題,我解了很久,今天終於在一個大陸的網站找到解答,有趣的是,對方是問另一個完全不相干的問題,我就在想,該不會這有影響吧!一試下去!果然就靈!只能說C++Builder…我真搞不懂你啊XD…

答案….使用動態調度DLL大法!!!!

改宣告

HANDLE hdDll;

int ( *Dll_SearchSolution)(char* info);

hdDll=LoadLibrary("MainAlgorithm.dll");//使用WinAPI

Dll_SearchSolution =  (int( *)(char* info))GetProcAddress(hdDll,"SearchSolution");

接下來改使用Dll_SearchSolution 取代原先的函數!解決!

問題:

我用BCB設計了一個視窗,想讓使用者調整大小,但不希望樣式被破壞,因此想要限制使用者縮小視窗最小寬度或高度、我該怎麼設計?

笨的解法:

在FormResize事件當中限制能縮的大小,比方說:

if(Form1->Width<300) Form1->Width=300;

但這樣使用者縮視窗時後、會有震動的問題

聰明解法:

直接在初始化時後設定

Form1->Constraints->MinWidth=800;

就可以了!