简体   繁体   English

Android NDK构建 - 包括LOCAL_SHARED_LIBRARIES?

[英]Android NDK building - Include LOCAL_SHARED_LIBRARIES?

I'm having problems building a project under the Android NDK. 我在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... 那些作为-lsomeLib我添加了,但是作为LOCAL_SHARED_LIBRARIES的那些没有被包括在内似乎......

My Android.mk contains the following 我的Android.mk包含以下内容

LOCAL_SHARED_LIBRARIES += libutils libmedia libz libbinder LOCAL_SHARED_LIBRARIES + = libutils libmedia libz libbinder

  1. Where does ndk-build actually look for these libraries? ndk-build实际上在哪里寻找这些库?
  2. If I don't include the -lutils -lmedia -lz -lbinder, I am not able to even get to the linker error. 如果我不包含-lutils -lmedia -lz -lbinder,我甚至无法得到链接器错误。 I have a feeling including just -LsomeDir and -lsomeLib is not the correct way to add them. 我有一种感觉,包括-LsomeDir和-lsomeLib不是添加它们的正确方法。

Here is the complete Android.mk. 这是完整的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). 与这些库特别相关的许多错误之一(即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. 在我看来,你不应该在你的LOCAL_LDLIBS参数中包含-lmedia等。

1. Where does ndk-build actually look for these libraries? 1. ndk-build实际上在哪里寻找这些库?

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. 如果您查看$NDK/docs/STABLE-APIS.html您将看到有一组指定的库可以这种方式包含在内。 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. 看了我自己之后,那里没有你指定的库,尽管我只寻找API-14。


2. If I don't include the -lutils -lmedia -lz -lbinder, I am not able to even get to the linker error. 2.如果我不包含-lutils -lmedia -lz -lbinder,我甚至无法得到链接器错误。 I have a feeling including just -LsomeDir and -lsomeLib is not the correct way to add them. 我有一种感觉,包括-LsomeDir和-lsomeLib不是添加它们的正确方法。

If your libraries are just regular c/c++ libraries that you would #include you should use LOCAL_C_INCLUDES instead. 如果您的库只是常规的c / c ++库,那么#include应该使用LOCAL_C_INCLUDES

Also note, from $NDK/docs/ANDROID-MK.html : 另请注意,来自$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. 例如,您不需要列出Android.mk中生成的文件之间的头文件或显式依赖项。 The NDK build system will compute these automatically for you. NDK构建系统将自动为您计算这些。

In order to use other libraries in my native code, I simply #include it and then specify where to find the headers. 为了在我的本机代码中使用其他库,我只需#include它,然后指定在哪里找到标题。 Here's my LOCAL_C_INCLUDES : 这是我的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. 我希望这有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 有没有办法检查 LOCAL_SHARED_LIBRARIES 是否已成功集成到 android 应用程序中? - Is there a way to check that LOCAL_SHARED_LIBRARIES are integrate successfully in android application? LOCAL_SHARED_LIBRARIES使我的应用程序崩溃 - LOCAL_SHARED_LIBRARIES crashes my app LOCAL_SHARED_LIBRARIES和LOCAL_REQUIRED_MODULES之间的差异? - Differences between LOCAL_SHARED_LIBRARIES and LOCAL_REQUIRED_MODULES? Android NDK / JNI:构建依赖于其他共享库的共享库 - Android NDK/JNI: Building a shared library that depends on other shared libraries Android NDK共享库 - Android NDK shared libraries Android NDK并加入新的共享库 - Android NDK and dropping in new shared libraries 使用Android NDK构建共享库-未定义引用 - Building shared library with Android NDK - undefined references 如何在android ndk中添加多个共享库? - How to add multi shared libraries in android ndk? Android NDK构建共享库-正在终止-停止。 local_module_filename不得包含文件扩展名 - Android NDK building shared library - Aborting - stop. local_module_filename must not contain a file extension 使用Android NDK将共享库和静态库编译为共享库 - Compiling shared and static libraries into a shared library using the Android NDK
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM