Android NDK建筑 – 包括LOCAL_SHARED_LIBRARIES?

前端之家收集整理的这篇文章主要介绍了Android NDK建筑 – 包括LOCAL_SHARED_LIBRARIES?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在 Android NDK下构建项目时遇到问题.很可能是由于没有包括正确的共享/静态库.我添加的是-lsomeLib,但是没有包含LOCAL_SHARED_LIBRARIES的那些似乎…

我的Android.mk包含以下内容

LOCAL_SHARED_LIBRARIES = libutils libmedia libz libbinder

> ndk-build在哪里实际寻找这些图书馆?
>如果我不包括-lutils -lmedia -lz -lbinder,我甚至无法连接到链接错误.我有一种感觉,包括只有-LsomeDir和-lsomeLib不是正确的方法添加它们.

这是完整的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)

许多错误之一与这些库有关(即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':

解决方法

它看起来像我不应该在你的LOCAL_LDLIBS参数中包含-lmedia等.

ndk-build在哪里实际寻找这些图书馆?

如果您查看$NDK / docs / STABLE-APIS.html,您将看到可以以这种方式包含一组指定的库.注意:


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

看了我自己,没有一个你指定的库存在那里,虽然我只是在寻找API-14.

2.如果我不包括-lutils -lmedia -lz -lbinder,包括只有-LsomeDir和-lsomeLib不是正确的方法添加它们.

如果您的库只是常规的c / c库,那么您将#include应该使用LOCAL_C_INCLUDES.

另请注意,从$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.

为了在我的本机代码中使用其他库,我只需#include它,然后指定在哪里找到头.这是我的LOCAL_C_INCLUDES:

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

我希望这有帮助.

原文链接:https://www.f2er.com/android/313601.html

猜你在找的Android相关文章