我试图将 libspotify 用于 android 应用程序,但在构建我的 c 包装器时遇到了一些问题。我创建了一个非常小的包装器,它只询问 libspotify 它的版本是什么。
我的文件夹结构如下所示:
jni
|-libs
| |-Android.mk
| |-libspotify.so (symlink)
| |-libspotify.so.12 (symlink)
| |-libspotify.so.12.1.51
|
|-include
| |-libspotify
| |-api.h
|
|-Android.mk
|-spotifywrap.c
/jni/Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SHARED_LIBRARIES := libspotify
LOCAL_MODULE := spotifywrap
LOCAL_SRC_FILES := spotifywrap.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
include $(BUILD_SHARED_LIBRARY)
/jni/spotifywrap.c
include <jni.h>
include <libspotify/api.h>
jstring Java_com_example_ndktest_MainActivity_getBuild(JNIEnv * env, jobject this)
{
jstring result = (*env)->NewStringUTF( env, sp_build_id() );
return result;
}
/jni/libs/Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libspotify
LOCAL_SRC_FILES := libspotify.so
include $(PREBUILT_SHARED_LIBRARY)
当我运行 ndk-build 时,我得到了这个:
spotifywrap.c:6: undefined reference to `sp_build_id'
sp_build_id 是 api.h 中接口的一部分。
关于我做错了什么的任何想法?