21

我正在尝试Taglib为 Android 编译。我已经 Taglib这里下载了最新版本。在为构建编译它之后,arm-linux我已经成功地将它导入到我的应用程序中,但是当我尝试从中调用任何函数时,tag_c.h我收到以下错误:

SharedLibrary  : taglibwav.so
/home/test/workspacenew/Androidtaglibexample/obj/local/armeabi/
objs/squared/taglibwav.o: In function 
`Java_com_android_androidtag_WavFileDetails_taglibwav':
/home/test/workspacenew/Androidtaglibexample/jni/taglibwav.c:30: 
undefined reference to `taglib_set_strings_unicode'
collect2: ld returned 1 exit status
make: *** [/home/test/workspacenew/Androidtaglibexample/obj/
local/armeabi/taglibwav.so] Error 1

应用配置信息为:

标签库 ./configure :-

./configure CC="/home/hcl/taglib/taglib/toolchain/bin/arm-linux-androideabi-gcc"\
--host="arm-linux" \
--build="arm" \
--enable-static="no" \
--enable-shared="yes" \
--prefix="/home/test/workspacenew/Androidtaglibexample/jni/testtaglib/"\

安卓.mk:-

LOCAL_PATH := $(call my-dir)

#declare the prebuilt library
include $(CLEAR_VARS)
LOCAL_MODULE := taglibtest
LOCAL_SRC_FILES := testtaglib/lib/libtag.a
LOCAL_EXPORT_C_INCLUDES := testtaglib/include/taglib/
LOCAL_PRELINK_MODULE := true
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS) 
include $(call all-subdir-makefiles)
LOCAL_MODULE := taglibwav
LOCAL_SRC_FILES := taglibwav.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/testtaglib/include/taglib/
LOCAL_SHARED_LIBRARY := taglibtest
LOCAL_LDLIBS    := -llog -ljnigraphics -lz -lm -L$(SYSROOT)/usr/lib -llog 
include $(BUILD_SHARED_LIBRARY)


应用程序.mk:-

APP_ABI :=armeabi
APP_STL:=stlport_static


taglibwav.c :-

#include <jni.h>
#include <tag_c.h>
#include <android/log.h>
#ifndef FALSE
#define FALSE 0
#endif
.......
.......
JNIEXPORT void JNICALL Java_com_android_androidtag_WavFileDetails_taglibwav
  (JNIEnv * ev, jclass jc){
      int i;
      int seconds;
      int minutes;
      TagLib_File *file;  //<< accessed form tag_c.h : OK
      TagLib_Tag *tag;    //<< accessed form tag_c.h : OK
      const TagLib_AudioProperties *properties; //<<accessed form tag_c.h : OK
      taglib_set_strings_unicode(FALSE);//<<accessed form tag_c.h : GETTING ERROR
}
....
....

Android NDK 版本:- Android-Ndk-r7c

请指导我正确的方向来解决我做错的事情

4

5 回答 5

9

我想你可能需要-ltag_c在某个地方

于 2013-04-08T21:05:14.880 回答
1
  TagLib_File *file;  //<< accessed form tag_c.h : OK
  TagLib_Tag *tag;    //<< accessed form tag_c.h : OK
  const TagLib_AudioProperties *properties; //<<accessed form tag_c.h : OK
  taglib_set_strings_unicode(FALSE);//<<accessed form tag_c.h : GETTING ERROR

您无法访问的原因taglib_set_strings_unicode是因为TAGLIB_C_EXPORTtag_c.h 中定义的方式。

#if defined(_WIN32) || defined(_WIN64)
#ifdef MAKE_TAGLIB_C_LIB
#define TAGLIB_C_EXPORT __declspec(dllexport)
#else
#define TAGLIB_C_EXPORT __declspec(dllimport)
#endif
#elif defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 1)
#define TAGLIB_C_EXPORT __attribute__ ((visibility("default")))
#else
#define TAGLIB_C_EXPORT
#endif
...
typedef struct { int dummy; } TagLib_File;
typedef struct { int dummy; } TagLib_Tag;
typedef struct { int dummy; } TagLib_AudioProperties;
...
TAGLIB_C_EXPORT void taglib_set_strings_unicode(BOOL unicode);
...
于 2013-04-10T01:13:36.163 回答
0

为了完成这项工作,我将在第 43 行修改 tag_c.h以定义正确的可见性规则:

#define TAGLIB_C_EXPORT __attribute__ ((visibility("default")))

如果这可行,您可能会在 taglib 上打开一个错误并链接回这个问题。

于 2013-04-15T10:56:15.267 回答
0
LOCAL_STATIC_LIBRARY := taglibtest

您正在使用静态库,而不是共享的。使用 shared one 的指令会混淆构建环境。

于 2013-04-15T21:50:59.200 回答
0

您需要链接tag_c.h.o 和taglibwav.o :

gcc -o program tag_c.h taglibwav.c
于 2013-04-18T10:51:40.723 回答