无法使用静态库构建共享库

时间:2011-08-01 12:33:04

标签: android android-ndk

我无法使用静态库构建共享库 我从网上下载了一些代码,我试图将它作为我的android项目的lib,但是我无法为它创建共享库。

请在下面找到我的Android.mk文件

LOCAL_PATH := $(call my-dir)
MY_PATH := $(LOCAL_PATH)

include $(CLEAR_VARS)
LOCAL_CFLAGS := -DFIXED_POINT -DEXPORT=""
LOCAL_EXPORT_LDLIBS := -llog
LOCAL_MODULE := dspmath
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include $(LOCAL_PATH)/code $(LOCAL_PATH)/dsp_fx \
$(LOCAL_PATH)/dspmath $(LOCAL_PATH)/ttylib
LOCAL_SRC_FILES := \
dspmath/ehwutl.c    dspmath/mathadv.c   dspmath/mathevrc.c \
dspmath/globdefs.c  dspmath/mathdp31.c
include $(BUILD_SHARED_LIBRARY)



include $(CLEAR_VARS)
LOCAL_CFLAGS := -DFIXED_POINT -DEXPORT=""
LOCAL_MODULE := dsp_fx
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include $(LOCAL_PATH)/code $(LOCAL_PATH)/dsp_fx \
$(LOCAL_PATH)/dspmath $(LOCAL_PATH)/ttylib
LOCAL_SRC_FILES := \
dsp_fx/basic_op.c    dsp_fx/lib_wmp_fx.c  dsp_fx/math_adv40.c  dsp_fx/math_ext40.c \
dsp_fx/basic_op40.c  dsp_fx/math_adv.c    dsp_fx/math_ext32.c
include $(BUILD_SHARED_LIBRARY)



include $(CLEAR_VARS)
LOCAL_CFLAGS := -DFIXED_POINT -DEXPORT=""
LOCAL_MODULE := ttylib
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include $(LOCAL_PATH)/code $(LOCAL_PATH)/dsp_fx \
$(LOCAL_PATH)/dspmath $(LOCAL_PATH)/ttylib
LOCAL_SRC_FILES := \
ttylib/bdo2dit.c   ttylib/tty_char.c  ttylib/tty_gen.c   ttylib/ttystate.c \
ttylib/dit2a.c     ttylib/tty_dbg.c   ttylib/tty_glob.c \
ttylib/tone_gen.c  ttylib/tty_dec.c   ttylib/tty_hdr.c \
ttylib/tty_bit.c   ttylib/tty_enc.c   ttylib/tty_rate.c
include $(BUILD_SHARED_LIBRARY)




include $(CLEAR_VARS)
LOCAL_CFLAGS := -DFIXED_POINT -DEXPORT=""
LOCAL_EXPORT_LDLIBS := -llog
LOCAL_MODULE := code
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include $(LOCAL_PATH)/code $(LOCAL_PATH)/dsp_fx \
$(LOCAL_PATH)/dspmath $(LOCAL_PATH)/ttylib
LOCAL_SRC_FILES := \
code/a2lsp.c     code/convh.c     code/fcbgq.c     code/inv_sqrt.c  code/putacbc.c \
code/acb_ex.c    code/cshift.c    code/fer.c       code/lpcana.c    code/r_fft.c \
code/acelp_pf.c  code/d3_10pf.c   code/filter.c    code/lsp2a.c     code/rda.c \
code/apf.c       code/d8_35pf.c   code/fndppf.c    code/lspmaq.c    code/rom.c \
code/auto.c      code/d_fer.c     code/getext1k.c  code/main.c      code/synfltr.c \
code/bitpack.c   code/d_globs.c   code/getgain.c   code/maxeloc.c   code/w2res.c \
code/bitupack.c  code/d_no_fer.c  code/getopt.c    code/mdfyorig.c  code/weight.c \
code/bl_intrp.c  code/d_rate_1.c  code/getres.c    code/mod.c       code/zeroinpt.c \
code/bqiir.c     code/decode.c    code/globs.c     code/ns127.c \
code/c3_10pf.c   code/durbin.c    code/impulser.c  code/pit_shrp.c \
code/c8_35pf.c   code/e_globs.c   code/interpol.c  code/pktoav.c \
code/comacb.c    code/encode.c    code/intr_cos.c  code/pre_enc.c
include $(BUILD_SHARED_LIBRARY)


LOCAL_PATH := $(MY_PATH)
include $(CLEAR_VARS)
LOCAL_CFLAGS := -DFIXED_POINT -DEXPORT=""
LOCAL_MODULE := evrc
LOCAL_SHARED_LIBRARIES := dspmath code dsp_fx ttylib
include $(BUILD_SHARED_LIBRARY)

执行上面的make文件后,我得到了像这样的diff文件夹中的输出 1)上面的make文件位于$(PROJECT)/ jni文件夹中 2)Outpur文件是在$(PROJECT)/ obj / local / armeabi

中生成的
-rwxr-xr-x+ 1 TPRM73 Domain Users 468K Aug  1 17:40 libcode.a
-rwxr-xr-x+ 1 TPRM73 Domain Users  80K Aug  1 17:40 libdsp_fx.a
-rwxr-xr-x+ 1 TPRM73 Domain Users  73K Aug  1 17:40 libdspmath.a
-rwxr-xr-x+ 1 TPRM73 Domain Users 3.6K Aug  1 17:41 libevrc.so
-rwxr-xr-x+ 1 TPRM73 Domain Users 101K Aug  1 17:41 libttylib.a
drwxr-xr-x+ 1 TPRM73 Domain Users    0 Aug  1 17:40 objs

如果你观察libevrc.so的大小,它是3.6K,小于静态库。请帮助我解决上述问题。如果您想了解更多信息,请与我们联系。

谢谢&问候,
SSuman185

2 个答案:

答案 0 :(得分:2)

我们必须使用LOCAL_WHOLE_STATIC_LIBRARIES 而不是 LOCAL_STATIC_LIBRARIES,以避免删除未使用的函数,以便将整个静态库加载到共享库中。

这是我从谷歌那里得到的基本答案。任何人如果知道,请添加更多信息。

答案 1 :(得分:0)

[Dhanavel]:你是对的!!

我也遇到过类似的问题。将LOCAL_STATIC_LIBRARIES替换为LOCAL_WHOLE_STATIC_LIBRARIES后,将链接发生并最终生成。所以已生成。