android build static lib

时间:2012-04-06 08:45:02

标签: android android-ndk static-libraries

我计划将静态Linux .a库用于android。 我使用以下链接http://codingfreak.blogspot.in/2010/01/creating-and-using-static-libraries-in.html

创建了静态.a文件

我的Android应用程序中有以下Android.mk文件。

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)

当我使用ndk-build r7b构建应用程序时,它会出现以下错误。

С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

任何人都可以帮忙,我被困了很长时间,在这里...... 提前谢谢。

1 个答案:

答案 0 :(得分:1)