1 依賴準(zhǔn)備
安卓版終端應(yīng)用基于linux,工程使用cmake管理,需要如下材料:
ubuntu 14+/debian8+ 虛擬機(jī)或系統(tǒng), 編譯環(huán)境
sudo apt-get install build-essential cmake-
Android NDK, 版本:android-ndk-r10e, (注意再高一點(diǎn)的版本會(huì)有編譯問題,需手動(dòng)調(diào)整)
vi ~/.bashrc, 導(dǎo)出NDK路徑:
export ANDROID_NDK=/home/yaohongtao/tools/android-ndk-r10e
source ~/.bashrc, 刷新環(huán)境變量,使新設(shè)定的路徑生效ndk: http://dl.google.com/android/ndk/android-ndk-r10e-linux-x86_64.bin
all: http://www.cnblogs.com/yaotong/archive/2011/01/25/1943615.html protobuf https://github.com/google/protobuf.git
下載最新版本即可,默認(rèn)執(zhí)行源碼目錄下的autogen.sh:./autogen.sh生成配置文件,然后就可以
./configure
make -j4 && make install
ldconfig
注意:autogen.sh中需要下載gmock依賴,如果電腦無法訪問谷歌,則注釋掉下載這部分即可:
... ... ...
# Check that gmock is present. Usually it is already there since the
# directory is set up as an SVN external.
# if test ! -e gmock; then
# echo "Google Mock not present. Fetching gmock-1.7.0 from the web..."
# curl $curlopts -L -O https://github.com/google/googlemock/archive/release-1.7.0.zip
# unzip -q release-1.7.0.zip
# rm release-1.7.0.zip
# mv googlemock-release-1.7.0 gmock
# curl $curlopts -L -O https://github.com/google/googletest/archive/release-1.7.0.zip
# unzip -q release-1.7.0.zip
# rm release-1.7.0.zip
# mv googletest-release-1.7.0 gmock/gtest
# fi
set -ex
... ... ...
- protobuf-c [非必須] https://github.com/protobuf-c/protobuf-c.git
2 編譯庫
2.1 安裝庫依賴:
源碼目錄/depends
cd depends
mkdir build
cd build && cmake ..
make -j4 && make install
2.2 編譯源碼
源碼目錄:執(zhí)行./mkandroid.sh
3 會(huì)生成libechat.so
然后提交到安卓上層,更新生成新的APK, 即可。