Linux系統下編譯VLC for Android
操作步驟: 1、下載最新版本的Linux版jdk,將下載好的檔案解壓到/usr/android目錄下
tar zxvf jdk-10.0.2_linux-x64_bin.tar.gz
2、設定環境變數
使用sudo vi /etc/profile
命令編輯環境變數配置檔案,在最底下新增:(安裝目錄修改為自己的)
export JAVA_HOME=/usr/android/jdk-10.0.2 export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$ANDROID_NDK:$PATH export CLASSPATH=$CLASSPATH:.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
3、設定完成後通過source /etc/profile
命令重新載入環境變數
4、檢查是否配置成功
輸入java -version
命令, 顯示以下內容,則說明安裝配置成功:
java version "10.0.2" 2018-07-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.2+13)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.2+13, mixed mode)
unzip android-ndk-r14b-linux-x86_64.zip
2、解壓後使用sudo vi /etc/profile
export ANDROID_NDK=/usr/android/android-ndk-r14b
export PATH=$PATH:$ANDROID_NDK
3、設定完成後通過source /etc/profile
命令重新載入環境變數
二、下載配置SDK
下載地址:https://www.androiddevtools.cn/
操作步驟:
1、下載壓縮包並解壓到/usr/android/目錄下;
tar zxvf android-sdk_r24.4.1-linux.tgz.tar
2、進入到android-sdk-linux/tools 目錄下,使用./android update sdk -u
export ANDROID_SDK=/usr/android/android-sdk-linux
export PATH=$PATH:$ANDROID_SDK/tools:$ANDROID_SDK/platform-tools
4、設定完成後使用source /etc/profile
命令重新載入環境變數使配置生效
四、安裝Linux編譯開發工具
sudo apt-get install autoconf automake ant autopoint cmake build-essential libtool m4 patch pkg-config protobuf-compiler ragel subversion unzip git
- 如果是64位ubuntu,為了防止後面少走彎路,需要安裝32位的庫。
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install zlib1g:i386 libstdc++6:i386 libc6:i386
五、VLC編譯 1、下載VLC 原始碼
git clone https://code.videolan.org/videolan/vlc-android.git
2、 配置編譯後執行的裝置型別
開啟/etc/profile。在最後新增:export ANDROID_ABI=armeabi-v7a
,然後儲存退出,執行 source /etc/profile
命令重新載入環境變數:
3、為了提高編譯效率,可以在gradle.properties 檔案中新增下列資訊:
org.gradle.parallel=true
org.gradle.configureondemand=true
# If you have a BUNCH of RAM available
org.gradle.daemon=true
org.gradle.jvmargs=-Xmx2048M
4、進入到vlc-android目錄,執行sh compile.sh -a armeabi-v7a
命令開始編譯。
六、問題彙總
- 問題1:gradle檔案下載完成後,在下載vlc時候報錯,預設git庫太小不夠用 需要重新配置。
VLC source not found, cloning Cloning into ‘vlc’… remote: Counting objects: 553672, done. remote: Compressing objects: 100% (107988/107988), done. error: RPC failed; result=56, HTTP code = 2002 MiB | 304.00 KiB/s fatal: The remote end hung up unexpectedly fatal: early EOF fatal: index-pack failed
解決方法:通過git config --global http.postBuffer 524288000
命令修改git的傳輸位元組限制。
- 問題2:bootstrap failed
autoreconf: automake failed with exit status: 1 vlc: bootstrap failed
解決方法:多執行幾次sh compile.sh -a armeabi-v7a
就可以了。
- 問題3:缺少一個工具libtool
autoreconf: configure.in: tracing autoreconf: configure.in: not using Libtool autoreconf: running: /home/android/vlc-android/vlc/extras/tools/build/bin/autoconf --include=/home/android/vlc-android/vlc/contrib/arm-linux-androideabi/share/aclocal --force configure.in:74: error: possibly undefined macro: AC_DISABLE_SHARED If this token and others are legitimate, please use m4_pattern_allow. See the Autoconf documentation. configure.in:75: error: possibly undefined macro: AC_LIBTOOL_WIN32_DLL configure.in:76: error: possibly undefined macro: AC_PROG_LIBTOOL autoreconf: /home/android/vlc-android/vlc/extras/tools/build/bin/autoconf failed with exit status: 1 make: *** [.a52] Error 1 contribs: make failed
解決方法:通過sudo apt-get autoremove libtool
命令移除手動安裝的libtool,再執行sh compile.sh -a armeabi-v7a
會自動下載libtool。
- 問題4:gettext的版本號不對
androideabi/share/aclocal autoreconf: Entering directory `.’ autoreconf: running: autopoint --force autopoint: *** The AM_GNU_GETTEXT_VERSION declaration in your configure.ac file requires the infrastructure from gettext-0.19.3 but this version is older. Please upgrade to gettext-0.19.3 or newer. autopoint: *** Stop. autoreconf: autopoint failed with exit status: 1 make: *** [.gpg-error] Error 1 contribs: make failed
解決方法:
- 通過
gettext --version
命令檢視gettext版本號,顯示如下:
gettext (GNU gettext-runtime) 0.18.3
Copyright (C) 1995-1997, 2000-2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Ulrich Drepper.
- 通過
grep --include=configure.ac -rn AM_GNU_GETTEXT_VERSION .
命令檢視哪些檔案涉及版本號,顯示如下:
./vlc/configure.ac:493:AM_GNU_GETTEXT_VERSION([0.19.8])
./vlc/contrib/contrib-android-arm-linux-androideabi/gnutls/configure.ac:256:AM_GNU_GETTEXT_VERSION([0.19])
./vlc/contrib/contrib-android-arm-linux-androideabi/libgpg-error/configure.ac:154:AM_GNU_GETTEXT_VERSION([0.18.3])
- 修改以上檔案中AM_GNU_GETTEXT_VERSION為自己的版本號0.18.3。
- 問題5:安裝的libtool存在問題
…/configure: line 9945: syntax error near unexpected token
dlopen' ../configure: line 9945:
LT_INIT(dlopen win32-dll shared disable-static)’ vlc: configure failed
解決方法:進入vlc-android/vlc目錄下執行autoreconf
命令。