android NDK 编译 Platinum

    版本:Platinum-f4d639

    platinum这个开源项目比较强大,直接支持windows、linux、ios、android各种系统!

而且脚本已经帮我们写好了!!非常方便

(1)NDK用 android-ndk-r6(用r7 build失败,在编译到测试程序的时候报很多未定义)

(2)配置NDK环境

    下载ndk r6的版本,配置环境变量就一个即可:

export ANDROID_NDK_ROOT=/home/yanghaibing/android-ndk-r6b



    在ndk根目录下添加一个文件$NDK/out/host/config.mk,文件内容如下:

HOST_TAG := linux-x86
这个文件用来匹配Config.scons中的

### figure out the host config
try:
    host_config = open(ANRDOID_NDK_OUT+'/host/config.mk')
    HOST_CONFIG={}
    for line in host_config.readlines():
        pair = re.split('\s+:=\s+', line);
        if len(pair) == 2:
            HOST_CONFIG[pair[0]] = pair[1].rstrip()
            
    host_config.close()
except:
    platform_map = {'linux2':'linux-x86', 'darwin':'darwin-x86', 'cygwin':'windows'}
    if sys.platform not in platform_map:
        raise Exception('Unrecognized host platform')
    HOST_CONFIG={'HOST_TAG':platform_map[sys.platform]}



( Platinum/Build/Targets/arm-android-linux/Config.scons这个文件完全不需要去修改!不过有兴趣可以去分析下)

(3)指定 target

Command Line Examples (android):

        指定命令行选项执行 scons target=arm-android-linux build_config=Release

        如果没有scons,请先apt-get install下,使用命令方面的帮助请直接man即可

        这个target可以通过阅读README

* Linux, Cygwin, MacOSX, iOS以及android
    Open a shell, go to the Platinum root directory and type 'scons' (http://scons.org). 
    The output of the scons build will be found under Platinum/Build/Targets/{TARGET}/{Debug|Release}. 
    Additionally, the output is copied under Platinum/Targets/{TARGET}/{Debug|Release} for convenience when applicable.

注(如果不是太熟悉脚本,下面这些不修改为妙):

修改 Platinum/Build/Boot.scons 文件中 options.AddVariables(...) 直接写入上述2个选项为默认值,则执行 scons 命令时不必指定选项

options = Variables()
options.AddVariables(
EnumVariable('target', 'build target', 'arm-android-linux', allowed_values=['arm-android-linux']),
BoolVariable('stop_on_warning', 'Stop the build on warnings', False),
ListVariable('build_config', 'build configurations', 'Release', names=['Debug', 'Release'])
)

(4)查看生成的文件

        生成的文件目录在Platinum-f4d639/Platinum/Build/Targets/arm-android-linux/Release下面,

不带后缀的是可以在android上测试的c可执行程序,生成了很多*.a库,以及一个libPlatinumJNI.so库,这个库还没去分析提供了哪些

接口,后面继续研究。

(5)把测试程序和库拷贝到android平台在命令行下测试(我放在hi3716c的海思板子上测试)

         把所有的.a库和so库先拷贝到/system/lib下(测试用),以后java程序调用的时候安装apk后将放在data的某个子目录下

         执行./FileMediaServerTest    /mnt/sda/sda1/....mp3,并查看端口号,若启动正常将阻塞着,并看到一些信息

另一端在pc上用浏览器登录即可,正常情况下就能播放音乐文件了。

         测试程序相当好,对于我们对开源代码的调用有一定的帮助,所以仔细先阅读测试程序的写法相当有帮助,而且已经包含了

DMS、DMC、DMR的功能,目前发现DMP的媒体控制及播放功能测试程序没法测试。


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值