Ubuntu16 64位下編譯linphone-android

一、下載源碼

編譯linphone-android前,先得下載好linphone-android,關於下載方法可參見:linphone源碼下載及下載失敗解決方法

二、編譯說明

編譯方法參照 linphone-android源碼中README.md文件說明操作,特別是對於sdk和ndk版本的要求:

To build liblinphone for Android, you must:

  1. 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.

  2. Download the Android ndk (version r11c or 15) from google and add it to your path (no symlink !!!) and ANDROID_NDK environment variable.

  3. 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
  4. 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
    --help
    to see what these options are.

  5. Run 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
./prepare.py
。如果沒有任何error,直接進行step5。

在這裏我遇到兩個問題:
- 問題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庫文件。

這裏寫圖片描述
這裏寫圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章