首页 > 代码库 > VLC For Android Ubuntu14.04编译环境搭建

VLC For Android Ubuntu14.04编译环境搭建

        VLC多媒体播放器(英语:VLC media player,最初为VideoLAN Client,是VideoLAN计划的开放源代码多媒体播放器。)支持众多音频与视频解码器及文件格式,并支持DVD影音光盘,VCD影音光盘及各类流协议,它是一个开源并且支持多种平台。

官网:https://wiki.videolan.org/AndroidCompile#Get_VLC_Source

环境:

宿主机:Windows XP

虚拟机:VirtualBox-4.3.12-93733-Win.exe

虚拟机系统:ubuntu14.04

环境搭建要求:
在Linux系统上,我安装的是Ubuntu14.04
需要安装的工具:
apache-ant (or ant), autoconf, automake, autopoint, cmake, gawk (or nawk), gcc, g++, libtool, git,
m4, patch, pkg-config, ragel, subversion, unzip.
提示:
1、如果是编译Android-x86设备,应该安装yasm

一、Android SDK
1.创建一个名为android_tools的目录
2.到官网上下载最新的SDK http://developer.android.com/sdk/index.html
3.解压到android目录下
4.运行:tools/android (也可以运行: "tools/android update sdk -u -t platform,platform-tool,extra")
5.在tool目录,安装"SDK Platform Android 4.3, API 18",根据提示操作
注:VLC的工程属性文件project.properties的target=android-18一定是已经安装的,否则会报问题三:

二、Android NDK
1.确保SDK已经安装成功,NDK要r9 版本以上的,因为在compile.sh文件中已经配置好了,如果版本过低会提示:You need the NDKv9 or later
2.下载NDK for Linux http://developer.android.com/intl/zh-cn/tools/sdk/ndk/index.html
3.解压到android_tools目录下,确保和SDK放在同一目录下

注意安装SDK和NDK时一定要注意机器是64还是32位,下载对应的版本安装,否则会有一些莫名其妙的问题
SDK和NDK的安装,都是解压的当前目录android_tools下
dzt@dzt-VirtualBox:~/android_tools$ sudo tar -xvf /mnt/shared/android-ndk-r9d-linux-x86.tar.bz2
dzt@dzt-VirtualBox:~/android_tools$ sudo unzip /mnt/shared/adt-bundle-linux-x86-20140702.zip


三、配置环境变量

Environment setup
在~/.bashrc最后添加 sudo gedit ~/.bashrc
export ANDROID_SDK=/home/dzt/android_tools/adt-bundle-linux-x86_64-20140321/sdk
export ANDROID_NDK=/home/dzt/android_tools/android-ndk-r9d
export PATH=$PATH:$ANDROID_SDK/platform-tools:$ANDROID_SDK/tools

根据实际安装路径写

设置环境变量等效:
dzt@dzt-VirtualBox:~/android_tools$ sudo source ~/.bashrc

Devices在命令行中指定设备,这个不是在文件中配置的,每次编译后退出再进来都需要重新设置
root@dzt-VirtualBox:/home/dzt/android_vlc/android# export ANDROID_ABI=armeabi
root@dzt-VirtualBox:/home/dzt/android_vlc/android# export NO_FPU=1



四、编译
1.Get VLC Source
在之前创建的android目录下运行以下命令
git clone git://git.videolan.org/vlc-ports/android.git
2.Compile
运行:sh compile.sh
root@dzt-VirtualBox:/home/dzt/android_vlc/android# sh compile.sh
For an ARMv6 device without FPU:
$ export NO_FPU=1
For an ARMv5 device:
$ export NO_ARMV6=1

If you plan to use a release build, run ‘compile.sh release‘
VLC source not found, cloning
正克隆到 ‘vlc‘...
remote: Counting objects: 426425, done.
remote: Compressing objects: 100% (80869/80869), done.
remote: Total 426425 (delta 343977), reused 425830 (delta 343585)
接收对象中: 100% (426425/426425), 237.54 MiB | 201.00 KiB/s, done.
处理 delta 中: 100% (343977/343977), done.
检查连接... 完成。
Checking out files: 100% (3413/3413), done.
切换到一个新分支 ‘android‘
Building tools


我下载的是r9d
需要更新compile.sh文件,如果NDK版本过低或过高会提示:You need the NDKv9 or later
此时就需要修改compile.sh文件
root@dzt-VirtualBox:/home/dzt/android_vlc/android# gedit compile.sh


# try to detect NDK version
REL=$(grep -o ‘^r[0-9]*.*‘ $ANDROID_NDK/RELEASE.TXT 2>/dev/null|cut -b2-)
echo $REL    //打印出版本
case "$REL" in
    9|9*)       #主要修改这一行
        GCCVER=4.8
        CXXSTL="/"${GCCVER}
    ;;
    7|8|*)
        echo "You need the NDKv9 or later"
        exit 1
    ;;
esac


相关库的下载:http://download.videolan.org/pub/contrib/有可能会进不去,我是用了VPN

依赖的一些库,这些库在编译过程中会进行下载,但有可能会下载失败,此时就需要手动去下载,拷贝到这个目录下。

dzt@dzt-VirtualBox:~/android_vlc/android/vlc/contrib/tarballs$ ls
a52dec-0.7.4.tar.gz       libebml-1.3.0.tar.bz2      LibVNCServer-0.9.9.tar.gz
ffmpeg-2763179.tar.gz     libgcrypt-1.6.1.tar.bz2    libvorbis-1.3.4.tar.xz
flac-1.3.0.tar.xz         libgpg-error-1.13.tar.bz2  libxml2-2.9.1.tar.gz
freetype-2.5.3.tar.gz     libgsm_1.0.13.tar.gz       live.2014.05.27.tar.gz
fribidi-0.19.6.tar.bz2    libiconv-1.14.tar.gz       nettle-2.6.tar.gz
gmp-6.0.0.tar.bz2         libmad-0.15.1b.tar.gz      openjpeg-1.5.0.tar.gz
gnutls-3.1.25.tar.xz      libmatroska-1.4.1.tar.bz2  opus-1.1.tar.gz
jpegsrc.v9a.tar.gz        libmodplug-0.8.8.5.tar.gz  postproc-git.tar.gz
libass-0.11.2.tar.gz      libmpeg2-0.5.1.tar.gz      speexdsp-git.tar.gz
libdvbpsi-1.2.0.tar.bz2   libogg-1.3.2.tar.xz        speex-git.tar.gz
libdvdcss-1.2.13.tar.bz2  libpng-1.6.12.tar.xz       taglib-1.9.1.tar.gz
libdvdnav-git.tar.xz      libssh2-1.4.3.tar.gz       zlib-1.2.8.tar.gz
libdvdread-4.9.9.tar.bz2  libtheora-1.1.1.tar.xz
以上库的下载地址:http://pan.baidu.com/s/1jGJukq6

在编译过程中遇到的问题整理

问题一
=== configuring in gettext-runtime (/home/dzt/android_vlc/android/vlc/contrib/contrib-android-arm-linux-androideabi/gettext/gettext-runtime)
configure: running /bin/bash ./configure --disable-option-checking ‘--prefix=/home/dzt/android_vlc/android/vlc/contrib/arm-linux-androideabi‘ ‘--datarootdir=/home/dzt/android_vlc/android/vlc/contrib/arm-linux-androideabi/share‘ ‘--includedir=/home/dzt/android_vlc/android/vlc/contrib/arm-linux-androideabi/include‘ ‘--libdir=/home/dzt/android_vlc/android/vlc/contrib/arm-linux-androideabi/lib‘ ‘--build=i686-linux-gnu‘ ‘--host=arm-linux-androideabi‘ ‘--target=arm-linux-androideabi‘ ‘--program-prefix=‘ ‘--enable-static‘ ‘--disable-shared‘ ‘--disable-dependency-tracking‘ ‘--with-pic‘ ‘--disable-java‘ ‘--disable-native-java‘ ‘--without-emacs‘ ‘build_alias=i686-linux-gnu‘ ‘host_alias=arm-linux-androideabi‘ ‘target_alias=arm-linux-androideabi‘ ‘CC=arm-linux-androideabi-gcc --sysroot=/home/dzt/android_vlc/android/android-ndk-r9d/platforms/android-9/arch-arm‘ ‘CFLAGS= -g -mfpu=vfpv3-d16 -mcpu=cortex-a8 -mthumb -mfloat-abi=softfp -O2 -I/home/dzt/android_vlc/android/android-ndk-r9d/sources/cxx-stl/gnu-libstdc++/4.8/include -I/home/dzt/android_vlc/android/android-ndk-r9d/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I/home/dzt/android_vlc/android/vlc/contrib/arm-linux-androideabi/include -g‘ ‘LDFLAGS= -L/home/dzt/android_vlc/android/vlc/contrib/arm-linux-androideabi/lib‘ ‘CPPFLAGS= -g -mfpu=vfpv3-d16 -mcpu=cortex-a8 -mthumb -mfloat-abi=softfp -O2 -I/home/dzt/android_vlc/android/android-ndk-r9d/sources/cxx-stl/gnu-libstdc++/4.8/include -I/home/dzt/android_vlc/android/android-ndk-r9d/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I/home/dzt/android_vlc/android/vlc/contrib/arm-linux-androideabi/include‘ ‘CXX=arm-linux-androideabi-g++ --sysroot=/home/dzt/android_vlc/android/android-ndk-r9d/platforms/android-9/arch-arm‘ ‘CXXFLAGS= -g -mfpu=vfpv3-d16 -mcpu=cortex-a8 -mthumb -mfloat-abi=softfp -O2 -I/home/dzt/android_vlc/android/android-ndk-r9d/sources/cxx-stl/gnu-libstdc++/4.8/include -I/home/dzt/android_vlc/android/android-ndk-r9d/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I/home/dzt/android_vlc/android/vlc/contrib/arm-linux-androideabi/include -g‘ --cache-file=/dev/null --srcdir=.
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for arm-linux-androideabi-strip... arm-linux-androideabi-strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for arm-linux-androideabi-gcc... arm-linux-androideabi-gcc --sysroot=/home/dzt/android_vlc/android/android-ndk-r9d/platforms/android-9/arch-arm
checking whether the C compiler works... no
configure: error: in `/home/dzt/android_vlc/android/vlc/contrib/contrib-android-arm-linux-androideabi/gettext/gettext-runtime‘:
configure: error: C compiler cannot create executables
See `config.log‘ for more details
configure: error: ./configure failed for gettext-runtime
make: *** [.gettext] 错误 77

fix:
由于我的机器的32位的,我用了64位的软件,把SDK和NDK换成32位的就没这个问题了。


问题二:
checking whether byte ordering is bigendian... no
checking for pthread_create in -lpthread... no
configure: error: pthread needed
make: *** [.dvdnav] 错误 1

Fix:
我按照上面的步骤重新下载一遍就没有报这个错误。
我之前是
第一步git clone git://git.videolan.org/vlc-ports/android.git
再做后面的事,所以才报了这个问题,我全部删除后再按上面的步骤执行相当顺利。

问题三:
-set-mode-check:

-set-debug-files:

-check-env:
[checkenv] Android SDK Tools Revision 23.0.2
[checkenv] Installed at /home/dzt/android_tools/adt-bundle-linux-x86-20140702/sdk

-setup:
[echo] Project Name: VLC
[gettype] Project Type: Application

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
[getbuildtools] Using latest Build Tools: 20.0.0
[echo] Resolving Build Target for VLC...

BUILD FAILED
/home/dzt/android_tools/adt-bundle-linux-x86-20140702/sdk/tools/ant/build.xml:542: Unable to resolve project target ‘android-19‘

Total time: 6 seconds
make: *** [vlc-android/bin/VLC-debug.apk] 错误 1
rm android-libs/libmedia.c android-libs/libutils.c android-libs/libstagefright.c android-libs/libbinder.c
root@dzt-VirtualBox:/home/dzt/android_vlc/android#


Fix:
出错原因
BUILD FAILED
/home/dzt/android_tools/adt-bundle-linux-x86-20140702/sdk/tools/ant/build.xml:542: Unable to resolve project target ‘android-19‘
因为我没有安装"android-19"的SDK,
解决办法有两种
1、修改工程属性文件vlc-android/project.properties文件
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.

# Project target.

target=android-18
android.library.reference.1=../java-libs/appcompat
android.library.reference.2=../java-libs/SlidingMenu
android.library.reference.3=../java-libs/WheelView

2、安装"android-19"SDK即可,运行以下命令
root@dzt-VirtualBox:/home/dzt/android_tools/adt-bundle-linux-x86-20140702/sdk# tools/android

出现如下画面,下载你需要的SDK即可,但不一定都能下载,因为最近连google都无法连上,你懂的



总结:
在编译的过程中碰到很多问题,有问题可以先百度一下,看别人有没有碰到类似的情况,一般都能在网上找到答案,需要具体问题具体分析,如果找不到要想下自己执行的步骤跟官网上的是否一致;
实在没办法就按步骤多试几遍也许能行。

VLC For Android Ubuntu14.04编译环境搭建