开发者

Compiling tesseract through android NDK

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
m开发者_如何学Pythonake: *** 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜