Search code examples
javaandroidandroid-ndkjava-native-interfaceandroid.mk

How to use Android tesseract Android.mk files in my Android.mk?


I was digging on using android tesseract api in my project.

https://github.com/rmtheis/tess-two

I copied com_googlecode_leptonica_android and com_googlecode_tesseract_android directory from tess-two to my project jni directory, my jni folder structure:

Android.mk
Application.mk
com_googlecode_leptonica_android
com_googlecode_tesseract_android
main_jni.cpp
...other h and cpp files...

I'm not sure how to include the Android.mk files in com_googlecode_leptonica_android and com_googlecode_tesseract_android inside my Android.mk file in jni directory.

LOCAL_PATH := $(call my-dir)
TESSERACT_PATH := $(LOCAL_PATH)/com_googlecode_tesseract_android/src
LEPTONICA_PATH := $(LOCAL_PATH)/com_googlecode_leptonica_android/src
include $(call all-subdir-makefiles)
include $(CLEAR_VARS)
$(info $(NDK_MODULE_PATH))
LOCAL_CFLAGS :=  -Wno-psabi
LOCAL_LDLIBS += -L$(SYSROOT)/usr/lib -llog
LOCAL_STATIC_LIBRARIES += android_native_app_glue
FILE_LIST_CPP := $(wildcard $(LOCAL_PATH)/*.cpp) # finds all cpp files
LOCAL_SRC_FILES := $(FILE_LIST_CPP:$(LOCAL_PATH)/%=%)
LOCAL_CFLAGS += \
    -DDEBUG \
    -DDEFAULT_DIR=\"/default\"
LOCAL_MODULE    := MyModule

include $(BUILD_SHARED_LIBRARY)

which does not work.

How to get this work?


Solution

  • I couldn't compile Android.mk files in tess-two project, I just ended up with importing libtess.so and liblept.so files into my Android.mk as prebuilt library and I could use tesseract libraries in my jni file.