原创

Linux系统下编译VLC for Android

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/zhuyunier/article/details/82843958

一、下载配置JDK
下载地址:https://www.oracle.com/technetwork/java/javase/downloads/index.html

操作步骤:
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)

二、下载配置NDK
下载地址:https://developer.android.google.cn/ndk/downloads/
操作步骤:
1、下载压缩包并解压到/usr/android/目录下

unzip android-ndk-r14b-linux-x86_64.zip

2、解压后使用sudo vi /etc/profile命令配置环境变量,在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命令下载更新全部可安装的SDK版本;
3、配置环境变量
在文件/etc/profile末端添加如下两行:

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

解决方法:

  1. 通过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.
  1. 通过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])
  1. 修改以上文件中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命令。

  • 问题6:库路径寻找错误

Android NDK: WARNING:private_libs/Android.mk:anw.10: non-system libraries in linker flags: -lhardware
Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
Android NDK: current module
Android NDK: WARNING:private_libs/Android.mk:anw.13: non-system libraries in linker flags: -lhardware
Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
Android NDK: current module
Android NDK: WARNING:private_libs/Android.mk:anw.14: non-system libraries in linker flags: -lhardware
Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
Android NDK: current module
Android NDK: WARNING:private_libs/Android.mk:anw.18: non-system libraries in linker flags: -lhardware
Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
Android NDK: current module
Android NDK: WARNING:private_libs/Android.mk:anw.21: non-system libraries in linker flags: -lhardware
Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
Android NDK: current module
Android NDK: WARNING:private_libs/Android.mk:iomx.10: non-system libraries in linker flags: -lgcc -lstagefright -lmedia -lutils -lbinder -lcutils -lui
Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
Android NDK: current module
Android NDK: WARNING:private_libs/Android.mk:iomx.13: non-system libraries in linker flags: -lgcc -lstagefright -lmedia -lutils -lbinder -lcutils -lui
Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
Android NDK: current module
Android NDK: WARNING:private_libs/Android.mk:iomx.14: non-system libraries in linker flags: -lgcc -lstagefright -lmedia -lutils -lbinder -lcutils -lui
Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
Android NDK: current module

解决办法:修改libvlc/private_libs/Android.mk,添加以下部分:

LOCAL_LDLIBS     := -L$(ANDROID_PRIVATE_LIBDIR)/$(TARGET_TUPLE) 
LOCAL_SHARED_LIBRARIES := -lgcc -lstagefright -lmedia -lutils -lbinder -llog -lcutils -lui
LOCAL_LDLIBS     := -L$(ANDROID_PRIVATE_LIBDIR)/$(TARGET_TUPLE) 
LOCAL_SHARED_LIBRARIES := -llog -lhardware
文章最后发布于: 2018-09-27 14:09:39
展开阅读全文
0 个人打赏

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 终极编程指南 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览