2010-12-21 81 views
2

我目前正在嘗試使用Cygwin在Windows上使用NDK爲Android構建PocketSphinx庫。我有PocketSphinxAndroidDemo項目代碼。我還有pocketsphinx和shpinxbase項目作爲E:/ Development/CMUSphinx文件夾的子文件夾。使用Cygwin在Windows上使用NDK嘗試構建PocketSphinx for Android的問題

我試圖從項目文件夾使用ndk生成。在項目/ JNI /文件夾中的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 := E:/Development/CMUSphinx 

# 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_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 
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 
LOCAL_CFLAGS += -DHAVE_CONFIG_H 
LOCAL_CFLAGS += -DANDROID_NDK 

LOCAL_PATH := $(BASE_PATH) 
LOCAL_MODULE := pocketsphinx_jni 

LOCAL_SRC_FILES := pocketsphinx_wrap.c 

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) 

當我運行NDK-build命令我碰到下面的錯誤:

build-binary.mk:197: *** target pattern contains no '%'. Stop. 

我可訂做ndk樣品很好。任何線索是什麼導致這個錯誤?提前謝謝了!

+0

@Chris - 你可以請張貼這個答案嗎?你提到的驅動器號和路徑,實際上讓我對我的正確答案。我希望能夠將你的答案標記爲正確:)我添加了SPHINX_PATH:= $(shell cygpath -u $(SPHINX_PATH))在SPHINX_PATH聲明下,現在所有的工作都很好!謝謝! – 2010-12-21 18:59:08

回答

1

你知道這個項目以前是否使用cygwin構建過? Cygwin有許多古怪之處,從Windows驅動器字母與unix路徑的尷尬組合,到在異常集合路徑中解釋無意的雙斜線等等。您可以嘗試/ cygdrive/e /類型的路徑而不是驅動器盤符,但是誰知道這是否會有所幫助。

+0

此答案讓我到正確的地方。我添加了SPHINX_PATH:= $(shell cygpath -u $(SPHINX_PATH))在SPHINX_PATH聲明下,現在所有的工作都很棒!謝謝! – 2010-12-21 19:34:00

1

傑森, 你必須改變你的獅身人面像路徑cygwin的格式,即沒有 「:」
變化

SPHINX_PATH := E:/Development/CMUSphinx 

SPHINX_PATH := /cygdrive/e/Development/CMUSphinx 

這將解決該錯誤

3

賈森,編輯jni/Android.mk文件

更改行162:

LOCAL_STATIC_LIBRARIES := sphinxutil sphinxfe sphinxfeat sphinxlm pocketsphinx 

到:

LOCAL_STATIC_LIBRARIES := pocketsphinx sphinxlm sphinxfeat sphinxfe sphinxutil 

這將解決您的問題。