如何在android系统库从android.mk链接libmedia.so [英] How to link libmedia.so in android system library from android.mk

查看:1327
本文介绍了如何在android系统库从android.mk链接libmedia.so的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要创建一个使用Android系统的/一个球员的lib / libmedia.so。

I want to create a Player which uses Android system/lib/libmedia.so.

直接使用JNI来播放视频。

Directly use JNI to play a video.

在Android.mk,我添加了-lmedia对包括图书馆,但我不能直接链接这一点。

In Android.mk, i add "-lmedia" for including the library, but i can't link this directly.

这是我的过程。


  1. 写一个cpp文件,其中包括在某些libmedia.so头文件

  1. write a Cpp file which includes some header file in libmedia.so

在LOCAL_LDLIBS的Andr​​oid.mk加上-lmedia

add "-lmedia" in Android.mk of LOCAL_LDLIBS

如..

LOCAL_LDLIBS -lmedia -lstagefright

LOCAL_LDLIBS -lmedia -lstagefright

使用NDK的构建打造的.so

use ndk-build to build .so

出错!

是否有人有一些答案,帮助???

Does anybody have some answer to help???

推荐答案

libmedia.so libsinstructionght.so 不属于公共API的一部分。这意味着,在理论上,你不应该依靠他们。但在实践中,这些库中的所有设备present,但它们是不同的。

libmedia.so and libsinstructionght.so are not part of the public API. This means that in theory, you should not rely on them. In practice, though, these libraries are present on all devices, but they are different.

您可以从您的设备仿真器使用命令提取此二进制文件,甚至

You can extract this binary file from your device, or even from an emulator using command

adb pull /system/lib/libmedia.so C:/android-ndk/platforms/android-14/arch-arm/usr/lib

这将会把部份文件连同公共API,以便使用它与NDK的构建更容易。在另一方面,你应该知道的碎片不lnly不同级别的Andr​​oid之间,而且芯片组厂商,甚至模型。

This will put ths file together with the public API so that using it with ndk-build is easier. On the other hand, you should be aware of fragmentation not lnly between different levels of Android, but also chipsets, manufacturers, and even models.

要解决这个问题,我的的.so 从不同的设备放到不同的目录中的文件,并将其添加的的的一个链接器的路径,例如:

To handle this, I pull .so files from different devices into separate directories, and add one of them to the linker path, e.g.

LOCAL_LDLIBS += -Lc:/android/galaxys.4.1.2.system.lib


这上面的指令无法解决你面对你的方法的大问题。 libmedia.so 不打算被链接到用户的应用程序。它假定特权用户的情况下能够访问受保护的设备,如摄像头,codeCS和屏幕。


This instruction above can not resolve the big problem you are facing with your approach. libmedia.so is not intended to be linked to user apps. It assumes the context of a privileged user with access to protected devices, such as camera, codecs, and screen.

您可以充分利用这个库,如果你针对一个根深蒂固的设备,或prepare定制ROM。而知道自己在做什么,以及如何避免从系统中窃取重要资源。

You can make full use of this library if you target a rooted device, or prepare a custom ROM. And know what you are doing, and how to avoid stealing essential resources from the system.

否则,在连接媒体lib中非常小的收益。

Otherwise there is very little gain in linking the media lib.

这篇关于如何在android系统库从android.mk链接libmedia.so的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆