Android的NDK建筑 - 包括LOCAL_SHARED_LIBRARIES? [英] Android NDK building - Include LOCAL_SHARED_LIBRARIES?

查看:3051
本文介绍了Android的NDK建筑 - 包括LOCAL_SHARED_LIBRARIES?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在建设下的Andr​​oid NDK的一个项目的问题。最有可能的是由于正确的共享/静态库没有被包括在内。没有被包括那些为-lsomeLib我加了,但那些为LOCAL_SHARED_LIBRARIES似乎...

我的Andr​​oid.mk包含以下

LOCAL_SHARED_LIBRARIES + = libutils libmedia libz进行libbinder

  1. 在哪里NDK建造实际上看起来这些库?
  2. 如果我不包括-lutils -lmedia -lz -lbinder,我不能够,甚至得到了链接错误。我有包括刚才-LsomeDir和-lsomeLib不添加这些正确的方式感受。

下面是完整的Andr​​oid.mk。

  LOCAL_PATH:= /用户/凯文/桌面/ player2 /录像机/录像机/ JNI
LIBPLAYER_PATH:= $(LOCAL_PATH)/../../ LibPlayer

包括$(CLEAR_VARS)

$(警告Android的make文件:$(LOCAL_PATH)/Android.mk)
$(警告安卓SYSROOT:$(SYSROOT))
$(警告附加LD_LIBS:$(LOCAL_PATH)/ lib目录)

IFEQ($(BUILD_ID),MID)
        LOCAL_CFLAGS + = -DENABLE_FREE_SCALE
万一

LOCAL_MODULE:= libamplayerjni
LOCAL_SRC_FILES:= com_farcore_playerservice_AmPlayer.c sys_conf.c
LOCAL_ARM_MODE:=手臂
LOCAL_C_INCLUDES:= $(LIBPLAYER_PATH)/ amplayer /播放/包括\
    $(LIBPLAYER_PATH)/ amplayer /控制/包括\
    $(LIBPLAYER_PATH)/ AM codeC /包括\
    $(LIBPLAYER_PATH)/ amffmpeg \
    $(JNI_H_INCLUDE)\
    /安卓/ NDK /编译/工具/ Android的9工具链/ SYSROOT / usr / include目录\
    /安卓/ NDK /编译/平台/ Android的9 /弓臂/ usr / include目录\
    /Android/source_2.3/system/core/include \
    /Android/source_2.3/frameworks/base/include

LOCAL_LDLIBS:= -L /用户/凯文/桌面/ player2 /录像机/录像机/ JNI / lib目录-L $(SYSROOT)/ usr / lib目录-llog -lz -lm -ldl **  -  lmedia -lstagefright -lutils -lbinder  - lgcc -landroid -lc -lstdc ++ -lthread_db **

** LOCAL_STATIC_LIBRARIES:= libamplayer libam codeC了li​​bavformat libav codeC libavutil libamadec **
LOCAL_SHARED_LIBRARIES + = libutils libmedia libz进行libbinder

LOCAL_ preLINK_MODULE:= FALSE

包括$(BUILD_SHARED_LIBRARY)
 

一个专门为这些库相关的许多错误(即libmedia.so)。

<$p$p><$c$c>/Users/kevin/Desktop/player2/videoplayer/videoplayer/obj/local/armeabi-v7a/libamadec.a(android_out.o):在功能`android_uninit: /Users/kevin/Desktop/player2/videoplayer/LibPlayer/amadec/audio_out/android_out.cpp:220:未定义参考`安卓:: AudioTrack ::停止() /Users/kevin/Desktop/player2/videoplayer/LibPlayer/amadec/audio_out/android_out.cpp:228:未定义参考`安卓:: AudioTrack ::〜AudioTrack() /Users/kevin/Desktop/player2/videoplayer/videoplayer/obj/local/armeabi-v7a/libamadec.a(android_out.o):在功能`〜自​​动锁定:

解决方案

它看起来对我来说,你不应该包括 -lmedia 等在 LOCAL_LDLIBS 参数。

1。哪里NDK建造实际上看起来这些库?

如果你看一下 $ NDK /文档/稳定 - APIS.html 你会看到有一个指定的库可以包括以这种方式设置。注:

  

  对应于给定的API级别的头,现在可以在位于 $ NDK /平台/ android-&LT;水平&GT; /弓臂/ usr / include目录   

说完看着我,没有你指定的库存在那里,虽然我只找了API-14。


2。如果我不包括-lutils -lmedia -lz -lbinder,我不能够,甚至得到了链接错误。我有一种感觉,包括刚才-LsomeDir和-lsomeLib不添加这些正确的方式。

如果您的图书馆只是普通的C / C ++,你会的#include 你应该使用 LOCAL_C_INCLUDES 而不是图书馆。

另外请注意,从 $ NDK /文档/ ANDROID-MK.html

  
      
  • 在构建系统处理许多细节给你。例如,   不需要列出头文件之间或显式依赖   在你的Andr​​oid.mk生成的文件。 NDK的构建系统会   自动为您计算这些。
  •   

为了使用其他图书馆我的家乡code,我只是的#include ,然后指定在哪里可以找到头。这是我的 LOCAL_C_INCLUDES

  LOCAL_C_INCLUDES:= $(LOCAL_PATH)/共享/核心/ INC \
                    $(LOCAL_PATH)/共享/型号/ INC \
                    $(LOCAL_PATH)/共享/升压/包括
 

我希望这有助于。

I'm having problems building a project under the Android NDK. Most likely its due to the proper shared / static libraries not being included. The ones as -lsomeLib I added, but the ones as LOCAL_SHARED_LIBRARIES are not being included it seems...

My Android.mk contains the following

LOCAL_SHARED_LIBRARIES += libutils libmedia libz libbinder

  1. Where does ndk-build actually look for these libraries?
  2. If I don't include the -lutils -lmedia -lz -lbinder, I am not able to even get to the linker error. I have a feeling including just -LsomeDir and -lsomeLib is not the correct way to add them.

Here is the complete Android.mk.

LOCAL_PATH := /Users/kevin/Desktop/player2/videoplayer/videoplayer/jni
LIBPLAYER_PATH := $(LOCAL_PATH)/../../LibPlayer

include $(CLEAR_VARS)

$(warning Android make file: $(LOCAL_PATH)/Android.mk)
$(warning Android sysroot: $(SYSROOT))
$(warning Additional LD_LIBS: $(LOCAL_PATH)/lib)

ifeq ($(BUILD_ID),MID)
        LOCAL_CFLAGS += -DENABLE_FREE_SCALE
endif

LOCAL_MODULE    := libamplayerjni
LOCAL_SRC_FILES := com_farcore_playerservice_AmPlayer.c sys_conf.c
LOCAL_ARM_MODE := arm
LOCAL_C_INCLUDES := $(LIBPLAYER_PATH)/amplayer/player/include \
    $(LIBPLAYER_PATH)/amplayer/control/include \
    $(LIBPLAYER_PATH)/amcodec/include \
    $(LIBPLAYER_PATH)/amffmpeg \
    $(JNI_H_INCLUDE) \
    /Android/ndk/build/tools/android-9-toolchain/sysroot/usr/include \
    /Android/ndk/build/platforms/android-9/arch-arm/usr/include \
    /Android/source_2.3/system/core/include \
    /Android/source_2.3/frameworks/base/include

LOCAL_LDLIBS := -L/Users/kevin/Desktop/player2/videoplayer/videoplayer/jni/lib -L$(SYSROOT)/usr/lib -llog -lz -lm -ldl **-lmedia -lstagefright -lutils -lbinder -lgcc -landroid -lc -lstdc++ -lthread_db**

**LOCAL_STATIC_LIBRARIES := libamplayer libamcodec libavformat libavcodec libavutil libamadec**
LOCAL_SHARED_LIBRARIES += libutils libmedia libz libbinder 

LOCAL_PRELINK_MODULE := false

include $(BUILD_SHARED_LIBRARY)

One of many errors related specifically to those libraries (ie libmedia.so).

/Users/kevin/Desktop/player2/videoplayer/videoplayer/obj/local/armeabi-v7a/libamadec.a(android_out.o): In function `android_uninit':
/Users/kevin/Desktop/player2/videoplayer/LibPlayer/amadec/audio_out/android_out.cpp:220: undefined reference to `android::AudioTrack::stop()'
/Users/kevin/Desktop/player2/videoplayer/LibPlayer/amadec/audio_out/android_out.cpp:228: undefined reference to `android::AudioTrack::~AudioTrack()'
/Users/kevin/Desktop/player2/videoplayer/videoplayer/obj/local/armeabi-v7a/libamadec.a(android_out.o): In function `~Autolock':

解决方案

It looks to me like you should not be including -lmedia etc in your LOCAL_LDLIBS arguments.

1. Where does ndk-build actually look for these libraries?

If you look in $NDK/docs/STABLE-APIS.html you will see that there is a specified set of libraries you can include in this manner. Note:

The headers corresponding to a given API level are now located under $NDK/platforms/android-<level>/arch-arm/usr/include

Having looked myself, none of the libraries you specified exist there, although I only looked for API-14.


2. If I don't include the -lutils -lmedia -lz -lbinder, I am not able to even get to the linker error. I have a feeling including just -LsomeDir and -lsomeLib is not the correct way to add them.

If your libraries are just regular c/c++ libraries that you would #include you should use LOCAL_C_INCLUDES instead.

Also note, from $NDK/docs/ANDROID-MK.html:

  • The build system handles many details for you. For example, you don't need to list header files or explicit dependencies between generated files in your Android.mk. The NDK build system will compute these automatically for you.

In order to use other libraries in my native code, I simply #include it and then specify where to find the headers. Here's my LOCAL_C_INCLUDES:

LOCAL_C_INCLUDES := $(LOCAL_PATH)/shared/Core/inc \
                    $(LOCAL_PATH)/shared/Model/inc  \
                    $(LOCAL_PATH)/shared/boost/include

I hope this helps.

这篇关于Android的NDK建筑 - 包括LOCAL_SHARED_LIBRARIES?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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