1 依赖准备
安卓版终端应用基于linux,工程使用cmake管理,需要如下材料:
ubuntu 14+/debian8+ 虚拟机或系统, 编译环境
sudo apt-get install build-essential cmake
-
Android NDK, 版本:android-ndk-r10e, (注意再高一点的版本会有编译问题,需手动调整)
vi ~/.bashrc, 导出NDK路径:
export ANDROID_NDK=/home/yaohongtao/tools/android-ndk-r10e
source ~/.bashrc, 刷新环境变量,使新设定的路径生效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
下载最新版本即可,默认执行源码目录下的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 编译源码
源码目录:执行./mkandroid.sh
3 会生成libechat.so
然后提交到安卓上层,更新生成新的APK, 即可。