2

I am planning to user static Linux .a library into android. I have created static .a file using following link http://codingfreak.blogspot.in/2010/01/creating-and-using-static-libraries-in.html

i have following Android.mk file in my Android application.

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE:= first-prebuilt
LOCAL_SRC_FILES:= libarith.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY)


include $(CLEAR_VARS)
LOCAL_MODULE := test-main
LOCAL_STATIC_LIBRARIES := first-prebuilt
LOCAL_SRC_FILES := native.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
include $(BUILD_SHARED_LIBRARY)

When I build application using ndk-build r7b, it gives following error.

Сompile++ thumb  : test-main <= native.cpp
SharedLibrary  : libtest-main.so
/home/hiren/NDK-r7b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: /home/hiren/workspace/VideoTEST/obj/local/armeabi/libarith.a(addition.o): Relocations in generic ELF (EM: 3)
/home/hiren/workspace/VideoTEST/obj/local/armeabi/libarith.a: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
make: *** [/home/hiren/workspace/VideoTEST/obj/local/armeabi/libtest-main.so] Error 1

Can anyone help, I am stuck for a long time, here... Thanks in advance.

pepyakin
  • 2,217
  • 19
  • 31

1 Answers1

1

You need to build your static librariy in the android format. See also Error in linking C++ static library with android ndk(Error: file format not recognized)

Community
  • 1
  • 1
plaisthos
  • 6,255
  • 6
  • 35
  • 63