ndk-build无法构建PocketSphinxAndroidDemo项目

时间:2011-02-03 23:58:25

标签: android-ndk

我正在尝试使用“android-ndk-r5b”为Android构建PocketSphinx。

我单独使用“pocketsphinxx”和“sphinxbase”项目从“https://cmusphinx.svn.sourceforge.net/svnroot/cmusphinx/trunk/PocketSphinxAndroidDemo”下载了PocketSphinxAndroidDemo项目。

我在Windows 7上使用Cygwin运行“ndk-build”问题是生成所有静态库(.a文件)但由于以下引用错误而无法创建.so文件:

$ /cygdrive/c/android-ndk-r5b/ndk-build
Gdbserver      : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
Gdbsetup       : libs/armeabi/gdb.setup
SharedLibrary  : libpocketsphinx_jni.so
C:/eclipse/workspace/PocketSphinxAndroidDemo/obj/local/armeabi/libpocketsphinx.a
(pocketsphinx.o): In function `ps_reinit':
C:/eclipse/workspace/pocketsphinx/src/libpocketsphinx/pocketsphinx.c:228: undefi
ned reference to `logmath_get_base'
C:/eclipse/workspace/pocketsphinx/src/libpocketsphinx/pocketsphinx.c:231: undefi
ned reference to `logmath_free'
C:/eclipse/workspace/pocketsphinx/src/libpocketsphinx/pocketsphinx.c:232: undefi
ned reference to `logmath_init'
C:/eclipse/workspace/pocketsphinx/src/libpocketsphinx/pocketsphinx.c:293: undefi
ned reference to `ptmr_init'
C:/eclipse/workspace/PocketSphinxAndroidDemo/obj/local/armeabi/libpocketsphinx.a
(pocketsphinx.o): In function `ps_free':
C:/eclipse/workspace/pocketsphinx/src/libpocketsphinx/pocketsphinx.c:340: undefi
ned reference to `logmath_free'
C:/eclipse/workspace/PocketSphinxAndroidDemo/obj/local/armeabi/libpocketsphinx.a
(pocketsphinx.o): In function `ps_update_lmset':
C:/eclipse/workspace/pocketsphinx/src/libpocketsphinx/pocketsphinx.c:413: undefi
ned reference to `ngram_model_free'
C:/eclipse/workspace/PocketSphinxAndroidDemo/obj/local/armeabi/libpocketsphinx.a
(pocketsphinx.o): In function `ps_add_word':
C:/eclipse/workspace/pocketsphinx/src/libpocketsphinx/pocketsphinx.c:565: undefi
ned reference to `ngram_model_add_word'

指定了所有头文件路径。创建静态库没有问题,但是链接静态库以创建共享库存在问题。

这是我的“Android.mk”文件:

# Build the native component of the PocketSphinx library for Android.

# You MUST change this to the absolute path of the directory containing
# sphinxbase and pocketsphinx source code.
#SPHINX_PATH := $(HOME)/Projects/Sphinx/trunk
SPHINX_PATH := /cygdrive/c/eclipse/workspace

# Copy this Android.mk along with pocketsphinx_wrap.c and the contents of the 'edu' folder
# built by swig to the jni/ directory of your Android project.
BASE_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(SPHINX_PATH)/sphinxbase/include/android $(SPHINX_PATH)/sphinxbase/include
LOCAL_EXPORT_C_INCLUDES := $(SPHINX_PATH)/sphinxbase/include/android $(SPHINX_PATH)/sphinxbase/include
LOCAL_CFLAGS += -DHAVE_CONFIG_H
LOCAL_CFLAGS += -DANDROID_NDK

LOCAL_PATH := $(SPHINX_PATH)/sphinxbase/src/libsphinxbase/util
LOCAL_MODULE := sphinxutil

LOCAL_SRC_FILES := \
    bio.c \
    bitvec.c \
    case.c \
    ckd_alloc.c \
    cmd_ln.c \
    dtoa.c \
    err.c \
    errno.c \
    f2c_lite.c \
    filename.c \
    genrand.c \
    glist.c \
    hash_table.c \
    heap.c \
    huff_code.c \
    info.c \
    listelem_alloc.c \
    logmath.c.arm \
    matrix.c \
    mmio.c \
    pio.c \
    profile.c \
    sbthread.c \
    strfuncs.c \
    utf8.c

include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(SPHINX_PATH)/sphinxbase/include/android $(SPHINX_PATH)/sphinxbase/include
LOCAL_CFLAGS += -DHAVE_CONFIG_H
LOCAL_CFLAGS += -DANDROID_NDK

LOCAL_PATH := $(SPHINX_PATH)/sphinxbase/src/libsphinxbase/fe
LOCAL_MODULE := sphinxfe
LOCAL_ARM_MODE := arm

LOCAL_SRC_FILES := \
    fe_interface.c \
    fe_sigproc.c \
    fe_warp_affine.c \
    fe_warp.c \
    fe_warp_inverse_linear.c \
    fe_warp_piecewise_linear.c \
    fixlog.c

include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(SPHINX_PATH)/sphinxbase/include/android $(SPHINX_PATH)/sphinxbase/include
LOCAL_CFLAGS += -DHAVE_CONFIG_H
LOCAL_CFLAGS += -DANDROID_NDK

LOCAL_PATH := $(SPHINX_PATH)/sphinxbase/src/libsphinxbase/feat
LOCAL_MODULE := sphinxfeat

LOCAL_SRC_FILES := \
    agc.c \
    cmn.c \
    cmn_prior.c \
    feat.c \
    lda.c

include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(SPHINX_PATH)/sphinxbase/include/android $(SPHINX_PATH)/sphinxbase/include
LOCAL_CFLAGS += -DHAVE_CONFIG_H
LOCAL_CFLAGS += -DANDROID_NDK

LOCAL_PATH := $(SPHINX_PATH)/sphinxbase/src/libsphinxbase/lm
LOCAL_MODULE := sphinxlm

LOCAL_SRC_FILES := \
    fsg_model.c \
    jsgf.c \
    jsgf_parser.c \
    jsgf_scanner.c \
    lm3g_model.c \
    ngram_model_arpa.c \
    ngram_model_dmp.c \
    ngram_model_set.c \
    ngram_model.c

include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(SPHINX_PATH)/sphinxbase/include/android $(SPHINX_PATH)/sphinxbase/include \
                    $(SPHINX_PATH)/pocketsphinx/include $(SPHINX_PATH)/pocketsphinx/src/libpocketsphinx \
                    $(SPHINX_PATH)/pocketsphinx/src/gst-plugin $(SPHINX_PATH)/sphinxbase/include/sphinxbase
LOCAL_CFLAGS += -DHAVE_CONFIG_H
LOCAL_CFLAGS += -DANDROID_NDK

LOCAL_PATH := $(SPHINX_PATH)/pocketsphinx/src/libpocketsphinx
LOCAL_MODULE := pocketsphinx

LOCAL_SRC_FILES := \
    acmod.c     \
    bin_mdef.c    \
    blkarray_list.c   \
    dict.c     \
    dict2pid.c    \
    fsg_history.c   \
    fsg_lextree.c   \
    fsg_search.c   \
    hmm.c.arm     \
    mdef.c     \
    ms_gauden.c.arm    \
    ms_mgau.c.arm    \
    ms_senone.c.arm    \
    ngram_search.c   \
    ngram_search_fwdtree.c \
    ngram_search_fwdflat.c \
    phone_loop_search.c  \
    pocketsphinx.c \
    ps_lattice.c   \
    ps_mllr.c    \
    ptm_mgau.c.arm    \
    s2_semi_mgau.c.arm   \
    tmat.c     \
    vector.c

include $(BUILD_STATIC_LIBRARY)

# Create the dynamic library wrapper
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(SPHINX_PATH)/sphinxbase/include/android $(SPHINX_PATH)/sphinxbase/include \
                    $(SPHINX_PATH)/pocketsphinx/include $(SPHINX_PATH)/pocketsphinx/src/libpocketsphinx
LOCAL_CFLAGS += -DHAVE_CONFIG_H
LOCAL_CFLAGS += -DANDROID_NDK

LOCAL_PATH := $(BASE_PATH)
LOCAL_MODULE := pocketsphinx_jni

LOCAL_SRC_FILES := pocketsphinx_wrap.c

# See http://code.google.com/p/android/issues/detail?id=9439
PRIVATE_WHOLE_STATIC_LIBRARIES := \
    $(call static-library-path,sphinxutil) \
    $(call static-library-path,sphinxfe) \
    $(call static-library-path,sphinxfeat) \
    $(call static-library-path,sphinxlm) \
    $(call static-library-path,pocketsphinx)
LOCAL_STATIC_LIBRARIES := sphinxutil sphinxfe sphinxfeat sphinxlm pocketsphinx

include $(BUILD_SHARED_LIBRARY)

=============================================== ======================

提前感谢您的任何建议! gwofu

2 个答案:

答案 0 :(得分:2)

反转您的LOCAL_STATIC_LIBRARIES顺序正常

答案 1 :(得分:1)

为了扩展user642960的响应,我将Android.mk中的LOCAL_STATIC_LIBRARIES行更改为:

LOCAL_STATIC_LIBRARIES := pocketsphinx sphinxlm sphinxfeat sphinxfe sphinxutil

这样做之后,提交者描述的错误就消失了。我也升级了NDK,但这似乎并没有解决问题。