Crash when launching project with two .so files - android

I try to build my project, that have two .so files:
libTheGame.so
liblua.so
Both is in the apk, but project crash when I launch it with:
Caused by: java.lang.IllegalArgumentException: Unable to load native
library: /data/data/com.piotrekb.theGame/lib/libTheGame.so
I can build and lunch project with both so, but without lua library added to TheGame :/
But when I add
LOCAL_SHARED_LIBRARIES := lua
crash happen :/
This is my android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_ARM_MODE := arm
LOCAL_MODULE := lua
LOCAL_SRC_FILES := ./Libs/lua-5.2.0/src/llex.c \
./Libs/lua-5.2.0/src/lapi.c \
./Libs/lua-5.2.0/src/loadlib.c \
./Libs/lua-5.2.0/src/lvm.c \
./Libs/lua-5.2.0/src/lundump.c \
./Libs/lua-5.2.0/src/lauxlib.c \
./Libs/lua-5.2.0/src/lparser.c \
./Libs/lua-5.2.0/src/lgc.c \
./Libs/lua-5.2.0/src/lobject.c \
./Libs/lua-5.2.0/src/lstrlib.c \
./Libs/lua-5.2.0/src/lbaselib.c \
./Libs/lua-5.2.0/src/ldebug.c \
./Libs/lua-5.2.0/src/lmem.c \
./Libs/lua-5.2.0/src/ltable.c \
./Libs/lua-5.2.0/src/loslib.c \
./Libs/lua-5.2.0/src/ldo.c \
./Libs/lua-5.2.0/src/ltablib.c \
./Libs/lua-5.2.0/src/liolib.c \
./Libs/lua-5.2.0/src/ldump.c \
./Libs/lua-5.2.0/src/ldblib.c \
./Libs/lua-5.2.0/src/lstate.c \
./Libs/lua-5.2.0/src/lctype.c \
./Libs/lua-5.2.0/src/lcode.c \
./Libs/lua-5.2.0/src/lcorolib.c \
./Libs/lua-5.2.0/src/lzio.c \
./Libs/lua-5.2.0/src/lmathlib.c \
./Libs/lua-5.2.0/src/lbitlib.c \
./Libs/lua-5.2.0/src/ltm.c \
./Libs/lua-5.2.0/src/lstring.c \
./Libs/lua-5.2.0/src/lopcodes.c \
./Libs/lua-5.2.0/src/linit.c \
./Libs/lua-5.2.0/src/lfunc.c
LOCAL_LDLIBS := -lm
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := -I$(LOCAL_PATH)/Libs/cml-1_0_2 -I$(STLPORT_BASE)/stlport
LOCAL_MODULE := TheGame
LOCAL_SRC_FILES := ./UISystem/UISystem.cpp ./ScriptSystem/ScriptSystem.cpp ./World3D/World3D.cpp ./ResourceSystem/ResourceSystem.cpp ./Renderer/Image.cpp \
./Renderer/Model3D.cpp ./LevelSystem/LevelSystem.cpp ./Renderer/ShaderProgram.cpp ./Common/Common.cpp ./Common/Engine.cpp ./Common/InDataBunch.cpp \
./Common/OutDataBunch.cpp ./Input/Input.cpp ./Game/Game.cpp ./Renderer/GL20Renderer.cpp \
./EntitySystem/EntitySystem.cpp TheGame.cpp
LOCAL_LDLIBS := -lm -llog -landroid -lGLESv2 -lEGL
LOCAL_SHARED_LIBRARIES := lua ##this line causes crash
LOCAL_STATIC_LIBRARIES := android_native_app_glue
LOCAL_CFLAGS+=$(LOCAL_C_INCLUDES)
include $(BUILD_SHARED_LIBRARY)
$(call import-module,android/native_app_glue)
Do you have any idea how can I deal with this :/ ?
I looked into similar questions, but them don't help me.

I had very similar problem. Finally ended up compiling libraries in separate mk files.
I think this answer might help you. Android NDK linking

Related

java.lang.UnsatisfiedLinkError: cannot locate symbol from a dependent shared library

I saw some crash reports from few devices (all arm64 acrhitecture) that looked like that:
Fatal Exception: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_ZNK6TagLib4File10propertiesEv" referenced by "/data/app/com.app.my/lib/arm64/libtaglib-wrapper.so"...
at java.lang.Runtime.loadLibrary(Runtime.java:372)
at java.lang.System.loadLibrary(System.java:988)
at helpers.TagReaderService.(SourceFile)
The OS version affected is 5.1. Since I read that the same problem (but related to system dependencies) happens because of wrong APP_PLATFORM, I double checked that it was right and in fact I'm targeting android-16.
I should mention that the symbol is declared in another shared library taglib.so which is then linked to the second one taglib-wrapper.so.
I also performed an objdump of both
taglib.so:
0000000000140590 g DF .text 000000000000004c Base TagLib::File::properties() const
and taglib-wrapper.so:
0000000000000000 DF *UND* 0000000000000000 TagLib::File::properties() const
So the symbol get correctly propagated to the taglib-wrapper.so library.
Personally I'm using a arm64 device and have no issue.
I also checked that the Application.mk was not being ignored adding random chars to it and performing a Gradle build. No relevant NDK-config code inside gradle.build file.
You can file the cpp code on the Git repo.
Application.mk
APP_STL := c++_shared
APP_ABI := arm64-v8a x86 armeabi-v7a
APP_PLATFORM := android-16
APP_CPPFLAGS += -frtti -fexceptions
Android.mk
LOCAL_PATH:= $(call my-dir)
# ======= TagLib engine ============================
include $(CLEAR_VARS)
LOCAL_MODULE := taglib
LOCAL_C_INCLUDES := $(LOCAL_PATH)/taglib \
$(LOCAL_PATH)/taglib/ape \
$(LOCAL_PATH)/taglib/asf \
$(LOCAL_PATH)/taglib/dsf \
$(LOCAL_PATH)/taglib/ebml \
$(LOCAL_PATH)/taglib/ebml/matroska \
$(LOCAL_PATH)/taglib/flac \
$(LOCAL_PATH)/taglib/it \
$(LOCAL_PATH)/taglib/mod \
$(LOCAL_PATH)/taglib/mp4 \
$(LOCAL_PATH)/taglib/mpc \
$(LOCAL_PATH)/taglib/mpeg \
$(LOCAL_PATH)/taglib/mpeg/id3v1 \
$(LOCAL_PATH)/taglib/mpeg/id3v2 \
$(LOCAL_PATH)/taglib/mpeg/id3v2/frames \
$(LOCAL_PATH)/taglib/ogg \
$(LOCAL_PATH)/taglib/ogg/flac \
$(LOCAL_PATH)/taglib/ogg/opus \
$(LOCAL_PATH)/taglib/ogg/speex \
$(LOCAL_PATH)/taglib/ogg/vorbis \
$(LOCAL_PATH)/taglib/riff \
$(LOCAL_PATH)/taglib/riff/aiff \
$(LOCAL_PATH)/taglib/riff/wav \
$(LOCAL_PATH)/taglib/s3m \
$(LOCAL_PATH)/taglib/toolkit \
$(LOCAL_PATH)/taglib/trueaudio \
$(LOCAL_PATH)/taglib/wavpack \
$(LOCAL_PATH)/taglib/xm
FILE_LIST := $(wildcard $(LOCAL_PATH)/taglib/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/taglib/**/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/taglib/**/**/*.cpp)
FILE_LIST += $(wildcard $(LOCAL_PATH)/taglib/**/**/**/*.cpp)
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)
LOCAL_EXPORT_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
# ======= TagLib wrapper ===========================
include $(CLEAR_VARS)
LOCAL_MODULE := taglib-wrapper
LOCAL_C_INCLUDES := $(LOCAL_PATH)/taglib \
$(LOCAL_PATH)/taglib/ape \
$(LOCAL_PATH)/taglib/asf \
$(LOCAL_PATH)/taglib/dsf \
$(LOCAL_PATH)/taglib/ebml \
$(LOCAL_PATH)/taglib/ebml/matroska \
$(LOCAL_PATH)/taglib/flac \
$(LOCAL_PATH)/taglib/it \
$(LOCAL_PATH)/taglib/mod \
$(LOCAL_PATH)/taglib/mp4 \
$(LOCAL_PATH)/taglib/mpc \
$(LOCAL_PATH)/taglib/mpeg \
$(LOCAL_PATH)/taglib/mpeg/id3v1 \
$(LOCAL_PATH)/taglib/mpeg/id3v2 \
$(LOCAL_PATH)/taglib/mpeg/id3v2/frames \
$(LOCAL_PATH)/taglib/ogg \
$(LOCAL_PATH)/taglib/ogg/flac \
$(LOCAL_PATH)/taglib/ogg/opus \
$(LOCAL_PATH)/taglib/ogg/speex \
$(LOCAL_PATH)/taglib/ogg/vorbis \
$(LOCAL_PATH)/taglib/riff \
$(LOCAL_PATH)/taglib/riff/aiff \
$(LOCAL_PATH)/taglib/riff/wav \
$(LOCAL_PATH)/taglib/s3m \
$(LOCAL_PATH)/taglib/toolkit \
$(LOCAL_PATH)/taglib/trueaudio \
$(LOCAL_PATH)/taglib/wavpack \
$(LOCAL_PATH)/taglib/xm
LOCAL_SRC_FILES := taglib.cpp
LOCAL_LDLIBS := -llog
LOCAL_SHARED_LIBRARIES := taglib
include $(BUILD_SHARED_LIBRARY)
UPDATE:
I merged the two library inside an unique shared library. Now that same device (Meizu MX4) crashes at the first JNI call of that library:
java.lang.UnsatisfiedLinkError: No implementation found for void helpers.IOWrapper.initialize() (tried Java_helpers_IOWrapper_initialize and Java_helpers_IOWrapper_initialize__) at helpers.IOWrapper.initialize(Native Method) at helpers.IOWrapper.read(SourceFile:136) at helpers.IOWrapper.read(SourceFile:123) at helpers.TagReaderService$a.run(SourceFile:58) at java.lang.Thread.run(Thread.java:818)
How is possible that it's the only device crashing? I'm loading the library thought static declaration is the same Java class. I'm using extern C declaration to wrap the cpp file. Maybe it's because I'm missing JNIEXPORT and JNICALL?

Unable to compile harfbuz_ng library using NDK

I am developing an application in which i am using indic-text-renderer for devnagri text renderering.As this is NDK library;i am trying to compile it using ndk-build command.
But it gives me following error:
Android NDK: Trying to define local module 'harfbuzz_ng' in /cygdrive/d/Project_WorkSpace/indic-text-renderer//jni/harfbuzz-ng/Android.mk.
Android NDK: But this module was already defined by /cygdrive/d/Project_WorkSpace/indic-text-renderer//jni/harfbuzz-ng/Android.mk.
My android.mk file is:
LOCAL_PATH := $(call my-dir)
MY_LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_ARM_MODE := arm
LOCAL_MODULE := complex-script-rendering
LOCAL_C_INCLUDES := $(LOCAL_PATH)/freetype/include $(LOCAL_PATH)/harfbuzz-ng/src
LOCAL_SRC_FILES := complex-script-rendering.c
LOCAL_STATIC_LIBRARIES := ft2 harfbuzz
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
include $(MY_LOCAL_PATH)/freetype/Android.mk
include $(MY_LOCAL_PATH)/harfbuzz-ng/Android.mk
How can i resolve this error?
I am very new to the NDK programming,so pls let me know if this information is not sufficient
Edit:
freetype/Android.mk
ifndef USE_FREETYPE
USE_FREETYPE := 2.4.2
endif
ifeq ($(USE_FREETYPE),2.4.2)
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
# compile in ARM mode, since the glyph loader/renderer is a hotspot
# when loading complex pages in the browser
#
LOCAL_ARM_MODE := arm
LOCAL_SRC_FILES:= \
src/base/ftbbox.c \
src/base/ftbitmap.c \
src/base/ftfstype.c \
src/base/ftglyph.c \
src/base/ftlcdfil.c \
src/base/ftstroke.c \
src/base/fttype1.c \
src/base/ftxf86.c \
src/base/ftbase.c \
src/base/ftsystem.c \
src/base/ftinit.c \
src/base/ftgasp.c \
src/raster/raster.c \
src/sfnt/sfnt.c \
src/smooth/smooth.c \
src/autofit/autofit.c \
src/truetype/truetype.c \
src/cff/cff.c \
src/psnames/psnames.c \
src/pshinter/pshinter.c
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/builds \
$(LOCAL_PATH)/include
LOCAL_CFLAGS += -W -Wall
LOCAL_CFLAGS += -fPIC -DPIC
LOCAL_CFLAGS += "-DDARWIN_NO_CARBON"
LOCAL_CFLAGS += "-DFT2_BUILD_LIBRARY"
# the following is for testing only, and should not be used in final builds
# of the product
#LOCAL_CFLAGS += "-DTT_CONFIG_OPTION_BYTECODE_INTERPRETER"
LOCAL_CFLAGS += -O2
LOCAL_MODULE:= libft2
include $(BUILD_STATIC_LIBRARY)
endif
harfbuzz-ng/android.mk
LOCAL_PATH:= $(call my-dir)
HARFBUZZ_SRC_FILES = \
src/hb-blob.cc \
src/hb-buffer-serialize.cc \
src/hb-buffer.cc \
src/hb-common.cc \
src/hb-fallback-shape.cc \
src/hb-face.cc \
src/hb-font.cc \
src/hb-ot-tag.cc \
src/hb-set.cc \
src/hb-shape.cc \
src/hb-shape-plan.cc \
src/hb-shaper.cc \
src/hb-tt-font.cc \
src/hb-unicode.cc \
src/hb-warning.cc \
src/hb-ot-layout.cc \
src/hb-ot-map.cc \
src/hb-ot-shape.cc \
src/hb-ot-shape-complex-arabic.cc \
src/hb-ot-shape-complex-default.cc \
src/hb-ot-shape-complex-indic.cc \
src/hb-ot-shape-complex-indic-table.cc \
src/hb-ot-shape-complex-myanmar.cc \
src/hb-ot-shape-complex-sea.cc \
src/hb-ot-shape-complex-thai.cc \
src/hb-ot-shape-normalize.cc \
src/hb-ot-shape-fallback.cc
#############################################################
# build the harfbuzz library
#
include $(CLEAR_VARS)
LOCAL_ARM_MODE := arm
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES:= \
$(HARFBUZZ_SRC_FILES) \
src/hb-icu.cc
LOCAL_CPP_EXTENSION := .cc
LOCAL_SHARED_LIBRARIES := \
libcutils \
libicuuc \
libicui18n \
libutils
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/src \
external/icu4c/common
LOCAL_CFLAGS += -DHB_NO_MT -DHAVE_OT -DHAVE_ICU
LOCAL_LDLIBS += -lpthread
LOCAL_MODULE:= libharfbuzz_ng
include $(BUILD_SHARED_LIBRARY)
#############################################################
# build the harfbuzz static library
#
include $(CLEAR_VARS)
LOCAL_ARM_MODE := arm
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES:= \
$(HARFBUZZ_SRC_FILES) \
src/hb-ucdn.cc \
src/hb-ucdn/ucdn.c
LOCAL_CPP_EXTENSION := .cc
LOCAL_STATIC_LIBRARIES := libft2
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/src \
external/freetype/include
LOCAL_CFLAGS += -DHB_NO_MT -DHAVE_OT -DHAVE_UCDN -DHAVE_FREETYPE
LOCAL_LDLIBS += -lpthread
LOCAL_MODULE:= libharfbuzz_ng
include $(BUILD_STATIC_LIBRARY)
I tried removing the entire BUILD_SHARED_LIBRARY block and it stopped complaining about re-defining problem,because I wanted to compile harfbuzz-ng just as a static library. You may give it a try.
The last time I got this error,is when I cross compile freetype and use it as a PRE-built static library in my project,I exported the NDK-MODULE-PATH and yet there's a line in my jni/Android.mk written include $(MY_LOCAL_PATH)/freetype/Android.mk
So I just comment out this line and everything works fine.
Because when you set NDK-MODULE-PATH , the compiler will look into your PATH directory and search for Android.mk and compile the source with it. please reference this,and I hope it will help you .
my jni/Android.mk looks like this:
LOCAL_PATH := $(call my-dir)
MY_LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_ARM_MODE := arm
LOCAL_MODULE := complex-script-rendering
LOCAL_C_INCLUDES := $(LOCAL_PATH)/freetype/include $(LOCAL_PATH)/harfbuzz-ng/src
LOCAL_SRC_FILES := complex-script-rendering.c
LOCAL_STATIC_LIBRARIES := libfreetype libharfbuzz
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
$(call import-module,freetype)
#include $(MY_LOCAL_PATH)/freetype/Android.mk
include $(MY_LOCAL_PATH)/harfbuzz-ng/Android.mk
and harfbuzz-ng/Android.mk:
LOCAL_PATH:= $(call my-dir)
HARFBUZZ_SRC_FILES = \
src/hb-blob.cc \
src/hb-buffer-serialize.cc \
src/hb-buffer.cc \
src/hb-common.cc \
src/hb-fallback-shape.cc \
src/hb-face.cc \
src/hb-font.cc \
src/hb-ot-tag.cc \
src/hb-ft.cc \
src/hb-set.cc \
src/hb-shape.cc \
src/hb-shape-plan.cc \
src/hb-shaper.cc \
src/hb-tt-font.cc \
src/hb-unicode.cc \
src/hb-warning.cc \
src/hb-ot-layout.cc \
src/hb-ot-map.cc \
src/hb-ot-shape.cc \
src/hb-ot-shape-complex-arabic.cc \
src/hb-ot-shape-complex-default.cc \
src/hb-ot-shape-complex-indic.cc \
src/hb-ot-shape-complex-indic-table.cc \
src/hb-ot-shape-complex-myanmar.cc \
src/hb-ot-shape-complex-sea.cc \
src/hb-ot-shape-complex-thai.cc \
src/hb-ot-shape-normalize.cc \
src/hb-ot-shape-fallback.cc
#############################################################
# build the harfbuzz library
#
#
#include $(CLEAR_VARS)
#
#LOCAL_ARM_MODE := arm
#
#LOCAL_MODULE_TAGS := optional
#
#LOCAL_SRC_FILES:= \
# $(HARFBUZZ_SRC_FILES) \
# src/hb-icu.cc
#
#LOCAL_CPP_EXTENSION := .cc
#
#LOCAL_SHARED_LIBRARIES := \
# libcutils \
# libicuuc \
# libicui18n \
# libutils
#
#LOCAL_C_INCLUDES += \
# $(LOCAL_PATH)/src \
# external/icu4c/common
#
#LOCAL_CFLAGS += -DHB_NO_MT -DHAVE_OT -DHAVE_ICU
#
#LOCAL_LDLIBS += -lpthread
#
#LOCAL_MODULE:= libharfbuzz_ng
#
#include $(BUILD_SHARED_LIBRARY)
#############################################################
# build the harfbuzz static library
#
include $(CLEAR_VARS)
LOCAL_ARM_MODE := arm
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES:= \
$(HARFBUZZ_SRC_FILES) \
src/hb-ucdn.cc \
src/hb-ucdn/ucdn.c
LOCAL_CPP_EXTENSION := .cc
LOCAL_STATIC_LIBRARIES := libfreetype
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/src \
$(LOCAL_PATH)/src/hb-ucdn \
external/freetype/include
LOCAL_CFLAGS += -DHB_NO_MT -DHAVE_OT -DHAVE_UCDN -DHAVE_FREETYPE
LOCAL_LDLIBS += -lpthread
LOCAL_MODULE:= libharfbuzz
include $(BUILD_STATIC_LIBRARY)
and I have a build.sh file in my jni directory,which will exort my freetype module,quite simple:
export NDK_MODULE_PATH=/home/***/workspace/indic-text-renderer/jni
ndk-build
Besides all this, you will have to cross-compile freetype library.
Wish you good luck, it costs me almost a week.

Static Library Android

I'm trying to build the libpng library into a static library on Android, but it's not working! Every time I try to build it, it doesn't do anything. Below is the android make file
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CFLAGS :=
LOCAL_MODULE := libpng
LOCAL_SRC_FILES :=\
png.c \
pngerror.c \
pngget.c \
pngmem.c \
pngpread.c \
pngread.c \
pngrio.c \
pngrtran.c \
pngrutil.c \
pngset.c \
pngtrans.c \
pngwio.c \
pngwrite.c \
pngwtran.c \
pngwutil.c
LOCAL_LDLIBS := -lz
include $(BUILD_STATIC_LIBRARY)
And if I change the last line to
include $(BUILD_SHARED_LIBRARY)
it builds correctly! Any help?
In the same directory make an Application.mk file and enter the line:
APP_MODULES := your-android-library-as-defined-in-Android.mk

Android jni "No Rule to make Target issue"

I am trying to compile the project which i got from below link .
Github project fmpeg. But while compiling that to create .so files using andriod ndk version 5 i am getting the following issue . Please advice me to solve it .
make: *** No rule to make target `/cygdrive/D/Shakthi/jhotovy/jhotovy-android-ffmpeg-fab1412/Project/jni/ffmpeg/ffmpeg.c', needed by `/cygdrive/D/Shakthi/jhotovy/jhotovy-android-ffmpeg-fab1412/Project/obj/local/armeabi/objs/ffmpeg/ffmpeg/ffmpeg.o'. Stop.
My Android.mk file code.
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ffmpeg
FFMPEG_LIBS := $(addprefix ffmpeg/, \
libavdevice/libavdevice.a \
libavformat/libavformat.a \
libavcodec/libavcodec.a \
libavfilter/libavfilter.a \
libswscale/libswscale.a \
libavutil/libavutil.a \
libpostproc/libpostproc.a )
OGG_LIBS := $(addprefix libogg/output/lib/, \
libogg.a )
VORBIS_LIBS := $(addprefix libvorbis/output/lib/, \
libvorbis.a \
libvorbisenc.a \
libvorbisfile.a )
THEORA_LIBS := $(addprefix libtheora/output/lib/, \
libtheora.a \
libtheoraenc.a \
libtheoradec.a )
LOCAL_CFLAGS += -g -Iffmpeg -Ivideokit -Wno-deprecated-declarations
LOCAL_LDLIBS += -llog -lz $(FFMPEG_LIBS) $(THEORA_LIBS) $(OGG_LIBS) x264/libx264.a
LOCAL_SRC_FILES := ffmpeg_android/ffmpeg_android.c ffmpeg/ffmpeg.c ffmpeg/cmdutils.c
include $(BUILD_SHARED_LIBRARY)
# Use to safely invoke ffmpeg multiple times from the same Activity
include $(CLEAR_VARS)
LOCAL_MODULE := ffmpeginvoke
LOCAL_SRC_FILES := ffmpeg_invoke/ffmpeg_invoke.c
LOCAL_LDLIBS := -ldl
include $(BUILD_SHARED_LIBRARY)
Did you follow the instructions in "How to build it"?

Issue trying to build PocketSphinx for Android using the NDK on Windows with Cygwin

I'm currently trying to build the PocketSphinx library for Android using the NDK on Windows with Cygwin. I have the PocketSphinxAndroidDemo project code. I also have the pocketsphinx and shpinxbase projects as sub folders of the E:/Development/CMUSphinx folder.
I'm trying to build using ndk-build from the project folder. The Android.mk file in the /jni/ folder of the project looks like this -
# 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)
When I run the ndk-build command I get the following error:
build-binary.mk:197: *** target pattern contains no '%'. Stop.
I can build all the ndk samples just fine. Any clue what's causing this error? Many thanks in advance!
Jason, Edit jni/Android.mk file
Change Line 162 :
LOCAL_STATIC_LIBRARIES := sphinxutil sphinxfe sphinxfeat sphinxlm pocketsphinx
to :
LOCAL_STATIC_LIBRARIES := pocketsphinx sphinxlm sphinxfeat sphinxfe sphinxutil
That will resolve your issue.
Do you know if this project has been previously built using cygwin with success? Cygwin has a number of oddities, from the awkward combination of windows drive letters with unix paths, to interpreting an inadvertent double slash in an assembled path unusually, and more. You could try the /cygdrive/e/ type of path instead of a drive letter, but who knows if that will help.
Jason,
you have to change your sphinx path to cygwin format i.e without ":"
change
SPHINX_PATH := E:/Development/CMUSphinx
to
SPHINX_PATH := /cygdrive/e/Development/CMUSphinx
this will fix the error
I used following link for Building Pocketsphinx On Android On Windows
https://sites.google.com/site/opiatefuchs/home/pocketsphinxandroiddemo but it misses one step that #Hitesh mentioned about replacing LOCAL_STATIC_LIBRARIES in jni/Android.mk file and I was able to build to latest 0.8 version.. thanks #Hitesh

Categories

Resources