Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Taglib for Android

I am trying to compile Taglib for Android. I have downloaded the latest version for Taglib from here . After compiling it for arm-linux build I have successfully imported it in my application, but when I try to call any function from tag_c.h I am getting following error:

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

Application configuration information is:

Taglib ./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/"\

Android.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)


Application.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 Version :- Android-Ndk-r7c

Please, guide me in the right direction to fix what I'm doing wrong

like image 301
ρяσѕρєя K Avatar asked Apr 08 '13 19:04

ρяσѕρєя K


2 Answers

I think you might need -ltag_c in there somewhere

like image 130
Moog Avatar answered Nov 20 '22 06:11

Moog


  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

The reason you can't access taglib_set_strings_unicode is because of how TAGLIB_C_EXPORT is defined in tag_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);
...
like image 39
Duke Avatar answered Nov 20 '22 05:11

Duke