尝试使用NDK构建PocketSphinxAndroidDemo的问题

时间:2011-03-02 15:30:41

标签: android android-ndk swig android-ndk-r5 cmusphinx

我正在尝试编译PocketSphinxAndroidDemo,它提供了Android上CMU pocketsphinx语音识别器的示例实现。我第一次收到类似于讨论here的错误。执行ndk-build后,我收到了这个错误:

Gdbserver      : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
Gdbsetup       : libs/armeabi/gdb.setup
Compile thumb  : pocketsphinx_jni <= pocketsphinx_wrap.c
/home/nick/workspace/android/PocketSphinxDemo/jni/pocketsphinx_wrap.c:761:28: error: sphinxbase/err.h: No such file or directory
/home/nick/workspace/android/PocketSphinxDemo/jni/pocketsphinx_wrap.c: In function 'Java_edu_cmu_pocketsphinx_pocketsphinxJNI_Decoder_1processRaw_1_1SWIG_10':
/home/nick/workspace/android/PocketSphinxDemo/jni/pocketsphinx_wrap.c:1441: warning: assignment discards qualifiers from pointer target type
make: *** [/home/nick/workspace/android/PocketSphinxDemo/obj/local/armeabi/objs-debug/pocketsphinx_jni/pocketsphinx_wrap.o] Error 1

我尝试了重建sphinxbasepocketsphinx库以及使用ndk-build -B重建的建议,但这不起作用。然后我修改了jni / pocketsphinx.i swig文件以更改err.h的包含:

#include <pocketsphinx.h>
//#include <sphinxbase/err.h>
#include <err.h>

是否曾尝试编译PocketSphinxAndroidDemo的人遇到过这个问题?我的编辑似乎允许我进一步编译,但现在我得到与汇编相关的错误:

Gdbserver      : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
Gdbsetup       : libs/armeabi/gdb.setup
Compile thumb  : pocketsphinx_jni <= pocketsphinx_wrap.c
/home/nick/workspace/android/PocketSphinxDemo/jni/pocketsphinx_wrap.c: In function 'Java_edu_cmu_pocketsphinx_pocketsphinxJNI_Decoder_1processRaw_1_1SWIG_10':
/home/nick/workspace/android/PocketSphinxDemo/jni/pocketsphinx_wrap.c:1442: warning: assignment discards qualifiers from pointer target type
Compile thumb  : sphinxfeat <= cmn.c
/tmp/cceyE035.s: Assembler messages:
/tmp/cceyE035.s:655: Error: selected processor does not support `smull r1,r2,r0,r4'
/tmp/cceyE035.s:657: Error: unshifted register required -- `orr r1,r1,r2,lsl#20'
/tmp/cceyE035.s:932: Error: selected processor does not support `smull r1,r2,r0,r4'
/tmp/cceyE035.s:934: Error: unshifted register required -- `orr r1,r1,r2,lsl#20'
make: *** [/home/nick/workspace/android/PocketSphinxDemo/obj/local/armeabi/objs-debug/sphinxfeat/cmn.o] Error 1

同样,有谁知道如何解决这个问题?我还没有看到任何其他开发者抱怨这个问题,所以我对进一步犹豫不决。谢谢你的帮助。

2 个答案:

答案 0 :(得分:2)

显然,仍需要为ARM编译标记一些源代码。我修改了Android.mk的以下部分,将cmn.c和lda.c设置为使用ARM编译。

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.arm \
    cmn_prior.c.arm \
    feat.c \
    lda.c.arm

我仍然想知道是否有其他人必须这样才能让他们的代码成功编译。

答案 1 :(得分:1)

编辑文件jni / Android.mk

更改第162行:

LOCAL_STATIC_LIBRARIES := sphinxutil sphinxfe sphinxfeat sphinxlm pocketsphinx

到:

LOCAL_STATIC_LIBRARIES := pocketsphinx sphinxlm sphinxfeat sphinxfe sphinxutil