I am trying to compile tesseract for android using android ndk r5, code of tesseract is obtained by checking out http://code.google.com/p/tesseract-android-tools/, i am unable to compile tesseract and got errors,
Install : libjpeg.so => libs/armeabi/libjpeg.so
make: *** No rule to make target `//cygdrive/e/DemoExamples_WorkSpace/tesseract-android-tools/jni/../external/leptonlib-1.66/src/adaptmap.c', needed b
y `/cygdrive/e/DemoExamples_WorkSpace/tesseract-android-tools/obj/local/armeabi/objs/lept//cygdrive/e/DemoExamples_WorkSpace/tesseract-android-tools/j
ni/../external/leptonlib-1.66/src/adaptmap.o'. Stop.
Please help me to sort out this problem.
I had the same issue and I think I solved it. May be helpful for those who get similar errors:
On OSX, I just changed the Android.mk files by giving the absolute paths as follows
First: jni/Android.mk
TESSERACT_PATH := /Users/.../tesseract-android-tools/tesseract-android-tools/external/tesseract-3.00
LEPTONICA_PATH := /Users/.../tesseract-android-tools/tesseract-android-tools/external/leptonlib-1.66
LIBJPEG_PATH := /Users/.../tesseract-android-tools/tesseract-android-tools/external/libjpeg
Then: jni/com_googlecode_leptonica_android/Android.mk
REAL_LOCAL_PATH := /Users/.../tesseract-android-tools/tesseract-android-tools/jni/com_googlecode_leptonica_android
and jni/com_googlecode_tesseract_android/Android.mk accordingly.
I believe the problem is caused by the relative path which is returned by the following command:
$(call my-dir)
Then I needed to run the ndk-build as superuser and all compiled just fine.
Search for adaptmap among the makefiles. Build the makefile that creates this module first.
So, I have compiled in windows 7 and windows xp, but it´s an ugly workaround.
The basic problem is "LOCAL_PATH := "with blank value, I don´t know why cygwin have problem with this, so you have to change paths on Android.mk files to work.
I will refer for Android.mk using numbers, my jni path is:
-jni
Android.mk(1)
Aplication.Mk
-com_googlecode_tesseract_android(dir)
Android.mk(2)
tesseract(dir)
-com_googlecode_leptonica_android(dir)
Android.mk(3)
leptonlib(dir)
-libjpeg
Android.mk(4)
=================================
Android.mk(1)
Put tesseract and leptonica sources on googlecode subdirectories like this:
TESSERACT_PATH := $(call my-dir)/com_googlecode_tesseract_android/tesseract -- directory to source, change for respective name
LEPTONICA_PATH := $(call my-dir)/com_googlecode_leptonica_android/leptonlib -- directory to source, change for respective name
LIBJPEG_PATH := $(call my-dir)/libjpeg
=================================
Android.mk(2)
1 - Change:
LOCAL_PATH:=
to
LOCAL_PATH:= $(call my-dir)
2 - Change:
BLACKLIST_SRC_FILES := \
%endiantest.c \
%freetype.c \
%xtractprotos.c
LOCAL_SRC_FILES := \
$(filter-out $(BLACKLIST_SRC_FILES),$(wildcard $(LEPTONICA_PATH)/src/*.c))
to
LOCAL_SRC_FILES := \
leptonlib/src/adaptmap.c \
leptonlib/src/affine.c \
leptonlib/src/affinecompose.c \ ... continue (Put all the files on src directory, without files listed on blacklist).
Note: replace leptonlib for subrectory name of leptonlib source.
3- Change:
ifneq ($(TARGET_SIMULATOR),true)
LOCAL_SRC_FILES += \
$(REAL_LOCAL_PATH)/stdio/open_memstream.c \
$(REAL_LOCAL_PATH)/stdio/fopencookie.c \
$(REAL_LOCAL_PATH)/stdio/fmemopen.c
LOCAL_C_INCLUDES += \
$(REAL_LOCAL_PATH)/stdio
endif
# jni
LOCAL_SRC_FILES += \
$(REAL_LOCAL_PATH)/box.cpp \
$(REAL_LOCAL_PATH)/pix.cpp \
$(REAL_LOCAL_PATH)/pixa.cpp \
$(REAL_LOCAL_PATH)/utilities.cpp \
$(REAL_LOCAL_PATH)/readfile.cpp \
$(REAL_LOCAL_PATH)/writefile.cpp \
$(REAL_LOCAL_PATH)/jni.cpp
LOCAL_C_INCLUDES += \
$(REAL_LOCAL_PATH) \
$(LEPTONICA_PATH)/src
to
ifneq ($(TARGET_SIMULATOR),true)
LOCAL_SRC_FILES += \
stdio/open_memstream.c \
stdio/fopencookie.c \
stdio/fmemopen.c
LOCAL_C_INCLUDES += \
stdio
endif
# jni
LOCAL_SRC_FILES += \
box.cpp \
pix.cpp \
pixa.cpp \
utilities.cpp \
jni.cpp
LOCAL_C_INCLUDES += \
leptonlib/src
=================================
Android.mk(3)
1 - Change:
LOCAL_PATH:=
to
LOCAL_PATH:= $(call my-dir)
2 - Change
On LOCAL_SRC_FILES change $(TESSERACT_PATH) to tesseract --Note: replace tesseract for subrectory name of tesseract source.
DON´T REPLACE $(TESSERACT_PATH) on LOCAL_C_INCLUDES only LOCAL_SRC_FILES.
DON´T REPLACE $(LEPTONICA_PATH) on LOCAL_C_INCLUDES.
3 - Change:
In #jni
LOCAL_SRC_FILES += \
$(REAL_LOCAL_PATH)/tessbaseapi.cpp
LOCAL_C_INCLUDES += \
$(REAL_LOCAL_PATH) \
$(TESSERACT_PATH)/api \
$(LEPTONICA_PATH)/src
to
LOCAL_SRC_FILES += \
tessbaseapi.cpp
LOCAL_C_INCLUDES += \
$(LOCAL_PATH) \
$(TESSERACT_PATH)/api \
$(LEPTONICA_PATH)/src
For me working on windows 7, windows xp, Mac and Ubuntu.
Related
I am building AOSP Kitkat (4.4) and trying to find the Android.mk file that defines the libnfc-nci module. The libnfc_nci_jni module depends on this local shared library (Android.mk included below) and I want to see the source that generates this .so file. I know that the nfc.h exists in /hardware/libhardware/include/hardware/nfc.h, but that is only the headers.
As far as I know, the available tools for searching android source code are cgrep, jgrep, and resgrep. However, (to my knowledge) these don't search Android.mk files. Is there a tool that I'm missing that I can use to find the directory that contains the module libnfc-nci?
Here is the Android.mk for libnfc_nci_jni (found in /packages/apps/Nfc/nci/jni/Android.mk)
VOB_COMPONENTS := external/libnfc-nci/src
NFA := $(VOB_COMPONENTS)/nfa
NFC := $(VOB_COMPONENTS)/nfc
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_PRELINK_MODULE := false
ifneq ($(NCI_VERSION),)
LOCAL_CFLAGS += -DNCI_VERSION=$(NCI_VERSION) -O0 -g
endif
LOCAL_CFLAGS += -Wall -Wextra
define all-cpp-files-under
$(patsubst ./%,%, \
$(shell cd $(LOCAL_PATH) ; \
find $(1) -name "*.cpp" -and -not -name ".*") \
)
endef
LOCAL_SRC_FILES:= $(call all-cpp-files-under, .)
LOCAL_C_INCLUDES += \
bionic \
bionic/libstdc++ \
external/stlport/stlport \
external/libxml2/include \
external/icu4c/common \
frameworks/native/include \
libcore/include \
$(NFA)/include \
$(NFA)/brcm \
$(NFC)/include \
$(NFC)/brcm \
$(NFC)/int \
$(VOB_COMPONENTS)/hal/include \
$(VOB_COMPONENTS)/hal/int \
$(VOB_COMPONENTS)/include \
$(VOB_COMPONENTS)/gki/ulinux \
$(VOB_COMPONENTS)/gki/common
LOCAL_SHARED_LIBRARIES := \
libicuuc \
libnativehelper \
libcutils \
libutils \
liblog \
libnfc-nci \
libstlport
LOCAL_STATIC_LIBRARIES := libxml2
LOCAL_MODULE := libnfc_nci_jni
LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
I am running Ubuntu 14.04
I found libnfc-nci in /external/libnfc-nci after some more googling. It seems there is no better tool to search aosp for a module than google (unless you write your own script).
As Gabe Sechan noted, a grep solution is possible. Here is the command I used that seemed to do the trick (working directory is the root of AOSP).
grep -inIEr "LOCAL_MODULE := libnfc-nci" .
You should try :
godir libnfc-nci
It should give you options in case thete ae several such directories
The actual problem is with compiling native library using ndk-build - libiconv - that ZBar has in dependencies.
Did anyone successfully got ZBar to work on x64 Android device?
EDIT: To be more specific.
I followed all steps from this article:
http://danilogiulianelli.blogspot.com/2012/12/how-to-cross-compile-libiconv-for.html
Using libiconv version 1.13.1 - same as used in article.
Content of Android.mk file:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
TARGET_ARCH_ABI := arm64-v8a
LOCAL_MODULE := iconv
LOCAL_CFLAGS := \
-Wno-multichar \
-D_ANDROID \
-DLIBDIR="\"c\"" \
-DBUILDING_LIBICONV \
-DIN_LIBRARY
LOCAL_C_INCLUDES := \
../libiconv-1.13.1 \
../libiconv-1.13.1/include \
../libiconv-1.13.1/lib \
../libiconv-1.13.1/libcharset/include
LOCAL_SRC_FILES := \
../libiconv-1.13.1/lib/iconv.c \
../libiconv-1.13.1/lib/relocatable.c \
../libiconv-1.13.1/libcharset/lib/localcharset.c
include $(BUILD_SHARED_LIBRARY)
Then execution of ndk-build V=1 ends with an error:
(output omitted)
/Users/mrtowel/workspace/jni/../libiconv-1.13.1/libcharset/lib/localcharset.c:49:24: fatal error: langinfo.h: No such file or directory
# include <langinfo.h>
^
compilation terminated.
make: *** [/Users/mrtowel/workspace/obj/local/armeabi/objs/iconv/__/libiconv-1.13.1/libcharset/lib/localcharset.o] Error 1
Any help will be appreciated.
I have downloaded mdadm source code from below location
https://www.kernel.org/pub/linux/utils/raid/mdadm/
Copied these files at /system/extras/mdadm
And, added Android.mk file for the executable binary of mdadm.
But, I am seeing following error when I compiled it:
target thumb C: mdadm <= system/extras/mdadm/sg_io.c
**arm-linux-androideabi-gcc: fatal error: cannot specify -o with -c, -S or -E with multiple files**
compilation terminated.
make: *** [out/target/product/<prod_name>/obj/EXECUTABLES/mdadm_intermediates/sg_io.o] Error 1
Any pointers to resolve this issue. Thanks in advance.
My Android.mk file looks like
LOCAL_PATH := $(call my-dir)
mdadm_src_files := Build.c mdopen.c mdmon.c monitor.c \
managemon.c util.c maps.c mdstat.c \
sysfs.c policy.c lib.c Kill.c sg_io.c \
dlink.c super0.c super1.c super-intel.c \
super-mbr.c super-gpt.c super-ddf.c sha1.c \
crc32.c msg.c bitmap.c xmalloc.c platform-intel.c \
probe_roms.c config.c Manage.c Assemble.c Create.c Detail.c \
Examine.c Grow.c Monitor.c Query.c Incremental.c Dump.c
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(mdadm_src_files)
LOCAL_MODULE := mdadm
LOCAL_SHARED_LIBRARIES := libc
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../kernel/include/
LOCAL_C_INCLUDES +=
$(LOCAL_PATH)/../../../kernel/arch/arm/include/asm/*
include $(BUILD_EXECUTABLE)
I'm trying to compile some C++11 sources with Android NDK on Windows, but without much luck. Please note, that I've read some other questions about compiling C++11, but they didn't help much unfortunately.
I've downloaded the ADT Bundle and latest NDK (android-ndk-r9b-windows-x86.zip).
These are my configuration files:
Application.mk
APP_STL := gnustl_static
NDK_TOOLCHAIN_VERSION = 4.8
LOCAL_CPP_FEATURES += exceptions
LOCAL_CFLAGS += -std=c++11
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := procalc-core
LOCAL_SRC_FILES := pcc_arithmetics.cpp \
pcc_arithmetics_tools.cpp \
pcc_common.cpp \
pcc_core.cpp \
pcc_dms_tokenizer.cpp \
pcc_dynamic_numerics.cpp \
pcc_exceptions.cpp \
pcc_expressiontree.cpp \
pcc_expression_containers.cpp \
pcc_messages.cpp \
pcc_numerics.cpp \
pcc_resolvers.cpp \
pcc_syntaxtree.cpp \
pcc_tokenizer.cpp \
sm_Bignum.cpp \
sm_Math2D.cpp \
sm_MathNumerics.cpp \
ss_Streams.cpp
include $(BUILD_SHARED_LIBRARY)
Build command
cd %AndroidProjects%ProCalc\jni\
D:\Android\ndk\ndk-build
pause
The error
That's actually one of the errors, but it's clearly not recognizing new C++11 keywords like auto or nullptr.
D:/(path)/jni/pcc_arithmetics.cpp: In static member function 'static
ProCalcCore::BaseNumeric* (* ProCalcCore::Arithmetics::GetFunctionMethod(std::string))
(const std::vector<const ProCalcCore::BaseNumeric*>&)':
D:/(path)/jni/pcc_arithmetics.cpp:4077:11: error: 'nullptr' was not declared in
this scope
return nullptr;
^
What am I doing wrong?
LOCAL_CPP_FEATURES += exceptions
LOCAL_CFLAGS += -std=c++11
Should go into Android.mk file. Alternatively, you could put
APP_CFLAGS += -std=c++11
into Application.mk. You can also use APP_CPPFLAGS instead, so that the C sources in your project (if you choose to add them) could compile (the C compiler will not like -std=c++11).
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