一、下载源码
编译linphone-android前,先得下载好linphone-android,关于下载方法可参见:linphone源码下载及下载失败解决方法。
二、编译说明
编译方法参照 linphone-android源码中README.md文件说明操作,特别是对于sdk和ndk版本的要求:
To build liblinphone for Android, you must:
Download the Android sdk (API 26.0.1 at max) with platform-tools and tools updated to latest revision, then add both ‘tools’ and ‘platform-tools’ folders in your path and the android-sdk folder to ANDROID_HOME environment variable.
Download the Android ndk (version r11c or 15) from google and add it to your path (no symlink !!!) and ANDROID_NDK environment variable.
Install yasm, nasm, ant, python, intltoolize, cmake(3.7) and vim-common. * On 64 bits linux systems you’ll need the ia32-libs package. * With the latest Debian (multiarch),
you need this:
dpkg --add-architecture i386
aptitude update
aptitude install libstdc++6:i386 libgcc1:i386 zlib1g:i386 libncurses5:i386
Run
./prepare.py
in the top level directory. This will configure the build and generate a Makefile in the top level directory. Some
options can be passed to choose what you want to include in the build
and the platforms for which you want to build. Use./prepare.py
to see what these options are.
--helpRun the Makefile script in the top level directory,
make
.
三、编译步骤
step1: 下载Android sdk (最高不能超过API 26.0.1),然后配置环境变量。
打开终端,执行sudo gedit ~/.bashrc
后,在文件末尾添加:
# Android SDK
export ANDROID_HOME=/home/jinato/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
这里提醒下:
sdk路径在环境变量配置时使用ANDROID_HOME,与ReadMe文件中说明一致,不然在step3中会出现如下找不到sdk的问题:
A problem occurred configuring root project 'linphone-android'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
执行sudo source ~/.bashrc
激活使配置生效。
step2:下载Android ndk (version r11c or 15),我用的是r14b,然后配置环境变量。
打开终端,执行sudo gedit ~/.bashrc
后,在文件末尾添加:
# Android NDK
export ANDROID_NDK=/home/jinato/Android/android-ndk-r14b
export PATH=$ANDROID_NDK:$PATH
执行sudo source ~/.bashrc
激活使配置生效。
step3:安装编译所需软件。
根据Readme文件说明需要安装yasm nasm ant python intltoolize cmake vim-common ia32-libs(兼容32位)。
其中: intltoolize 已被 intltool取代; ia32-libs 已被 lib32ncurses5 lib32z1取代。
所以,执行以下安装:
sudo apt-get insatall yasm nasm ant python intltool cmake vim-common lib32ncurses5 lib32z1
step4:进入linphone-android源码目录cd linphone-android源码目录
,然后,执行sudo
。如果没有任何error,直接进行step5。
./prepare.py
在这里我遇到两个问题:
- 问题1:cmake版本要求至少3.7,但我要求上的版本是3.5,需要装更高版本。
解决方法:
a)cmake官网下载安装包,选择“XX.tar.gz”源码安装包 。我下的是目前最新版本cmake-3.10.0-rc2.tar.gz 。
b)执行命令:
$tar -zxvf cmake-3.10.0-rc2.tar.gz
$cd xx.tar.gzxx.tar.gz
$./bootstrap
$make
$make install
c)检查版本:
cmake –vision 或sudo cmake –vision
d)再次执行sudo ./prepare.py
- 问题2:没有接受SDK的license
Checking the license for package Android SDK Build-Tools 26.0.1 in /home/jinato/Android/Sdk/licenses
Warning: License for package Android SDK Build-Tools 26.0.1 not accepted.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'linphone-android'.
> You have not accepted the license agreements of the following SDK components:
[Android SDK Build-Tools 26.0.1].
Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 6s
解决方法:
a)执行cd $ANDROID_HOME/tools/bin
b)执行./sdkmanager --licenses
c)接受所有license
d)再次执行sudo ./prepare.py
step5:执行make
。
实际上就是编译经过step4后在linphone-android源码目录会生成一个Makefile文件。等待滚屏结束,编译就完成了,在源码目录下就会多出一些文件如liblinphone-sdk、libs文件中各种.so库文件。