我正在尝试在JNI代码中使用两个不同的库:
我尝试使用以下android.mk文件编译它们:
TOP_PATH := $(call my-dir)
# Lib native-audio-jni
#------------------------------------------------------------------------------------------------------
APP_PLATFORM := android-19
LOCAL_PATH := $(TOP_PATH)
include $(CLEAR_VARS)
LOCAL_MODULE := native-audio-jni
LOCAL_SRC_FILES := native-audio-jni.c \ wavfile.c
# for native audio
LOCAL_LDLIBS += -lOpenSLES
# for logging
LOCAL_LDLIBS += -llog
# for native asset manager
LOCAL_LDLIBS += -landroid
include $(BUILD_SHARED_LIBRARY)
#For libsndfile-android
#--------------------------------------------------------------------------------
include $(CLEAR_VARS)
LOCAL_PATH := $(TOP_PATH)/libsndfile-android
OGG_ROOT := $(LOCAL_PATH)/deps/libogg/include
VORBIS_ROOT := $(LOCAL_PATH)/deps/libvorbis/include
LOCAL_CFLAGS := -DHAVE_EXTERNAL_LIBS
LOCAL_C_INCLUDES := $(OGG_ROOT) $(VORBIS_ROOT)
LOCAL_MODULE := sndfile
OGG_SRC_FILES := deps/libogg/src/bitwise.c deps/libogg/src/framing.c
V_SRC := deps/libvorbis/src
VORBIS_SRC_FILES := $(V_SRC)/analysis.c $(V_SRC)/floor0.c $(V_SRC)/lsp.c $(V_SRC)/res0.c \
$(V_SRC)/vorbisfile.c $(V_SRC)/bitrate.c $(V_SRC)/floor1.c $(V_SRC)/mapping0.c $(V_SRC)/sharedbook.c \
$(V_SRC)/window.c $(V_SRC)/block.c $(V_SRC)/info.c $(V_SRC)/mdct.c $(V_SRC)/smallft.c \
$(V_SRC)/codebook.c $(V_SRC)/lookup.c $(V_SRC)/psy.c $(V_SRC)/synthesis.c \
$(V_SRC)/envelope.c $(V_SRC)/lpc.c $(V_SRC)/registry.c $(V_SRC)/vorbisenc.c
LOCAL_SRC_FILES := mat5.c windows.c G72x/g723_24.c G72x/g72x.c \
G72x/g723_40.c G72x/g721.c G72x/g723_16.c \
float32.c chanmap.c test_endswap.c rf64.c sndfile.c htk.c dither.c \
test_log_printf.c txw.c ms_adpcm.c ima_adpcm.c flac.c aiff.c \
wav.c macbinary3.c mat4.c pcm.c caf.c \
audio_detect.c id3.c alaw.c macos.c file_io.c broadcast.c double64.c \
raw.c test_broadcast_var.c \
g72x.c command.c chunk.c avr.c sd2.c voc.c test_audio_detect.c \
mpc2k.c gsm610.c dwd.c \
interleave.c common.c test_strncpy_crlf.c sds.c pvf.c paf.c au.c \
test_float.c \
vox_adpcm.c ulaw.c strings.c svx.c test_conversions.c rx2.c nist.c \
GSM610/code.c GSM610/gsm_destroy.c \
GSM610/gsm_decode.c GSM610/short_term.c GSM610/gsm_create.c \
GSM610/decode.c GSM610/gsm_option.c \
GSM610/long_term.c GSM610/table.c GSM610/rpe.c GSM610/preprocess.c \
GSM610/gsm_encode.c GSM610/lpc.c \
GSM610/add.c dwvw.c wav_w64.c wve.c ogg.c ogg_vorbis.c w64.c test_file_io.c\
ircam.c xi.c ima_oki_adpcm.c \
$(OGG_SRC_FILES) $(VORBIS_SRC_FILES)
LOCAL_LDLIBS := -llog
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := sndfilelib
LOCAL_STATIC_LIBRARIES := sndfile
include $(BUILD_SHARED_LIBRARY)
当我编译时,一切都运行良好,我在相应的架构文件夹中得到了两个共享库(.so)。
问题是,当我尝试使用在第二个库(本地静态库)中包含的一个.h文件中定义的函数时,会出现“未定义引用函数”的错误。
所以我认为应该有一种方法将该静态库链接到非静态库上。
我已经尝试在我尝试使用该函数的.m文件中导入.h文件,但没有任何变化。
请帮助我,感谢您的时间。