我在 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':