Error in compiling tesseract - android-ndk

I'm compiling tesseract-android-tools-1.00 by using android-ndk r8b(Tesseract-android-tools contain the android tools for compiling tesseract OCR,Leptonica and Jpeg libraries.)
The README file instructions say that the three libraries are to be put under "external" folder which is under the project folder(here "tesseract-android-tools-1.00" folder).
Then the folder structure would be :
tesseract-android-tools-1.00/external/libjpeg/
tesseract-android-tools-1.00/external/tesseract-3.00/
tesseract-android-tools-1.00/external/leptonlib-1.66/
When I run ndk-build under project folder(tesseract-android-tools-1.00 folder),I got the following error.
G:\eclipse\ws\tesseract-android-tools-1.00>ndk-build
Install : libjpeg.so => libs/armeabi/libjpeg.so
make: * No rule to make target /jni/com_googlecode_lepttonica_android/stdio/open_memstream.c', needed byobj/local/armeabi/objs/lept/jni/com_googlecode_leptonica_android/stdio/open_memstream.o'. Stop.
Before this error,I've come through some errors such as "**No rules to make target..", "**No target found..,needed by ..".
I fixed the errors by modifing the content of tesseract-android-tools-1.00/jni/Android.mk file,
from...
.........
# TESSERACT_PATH :=
# LEPTONICA_PATH :=
# LIBJPEG_PATH := "
.........
to...
............
TESSERACT_PATH := external/tesseract-3.00
LEPTONICA_PATH := eclipse/ws/tesseract-android-tools-1.00/external/leptonlib-1.66
LIBJPEG_PATH := g:/eclipse/ws/tesseract-android-tools-1.00/external/libjpeg
...........
I've to do this because I'm using on Windows7 and cannot perform Linux commands as shown in README file...
export TESSERACT_PATH=${PWD}/tesseract-3.00
export LEPTONICA_PATH=${PWD}/leptonlib-1.66
export LIBJPEG_PATH=${PWD}/libjpeg"
Note:I downloaded libjpeg from github ... as a tag of android-2.2.3_r2.1-0

The tesseract-android-tools-1.00 file in the Downloads section is old and doesn't work.
Instead, you should clone the latest code from the repository using this command:
git clone https://code.google.com/p/tesseract-android-tools/

Related

linking shared libraries with cmake on ubuntu

I am trying to link to shared object library (json-c) using cmake. I am a super beginner with cmake, and have tried the solutions in various SO posts to no avail.
I am following the directions laid out here
first step is to build the json-c library, which I did sucesfully.
Second step is linking to it. That's what I am having issues with. After following these instructions, my project directory structure looks like this:
Project Structure (before running make, build directory was empty)
base
|-json-c-master
|-libjson-c.so
|-libjson-c.a
|-json.h
:
:
:
|-CMakeLists.txt
|-Makefile
|-libjson-c.so
|-build
|-CMakeFiles
|-
:
:
|-Makefile.
|-src
|-main.c
|-project1.c
|-project1.h
The contents of my CMakeLists.txt in ~/base/project1/CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(project1) set(CMAKE_CXX_STANDARD 14)
set(SOURCES src/main.c src/project1.h src/project1.c )
add_executable(project1 ${SOURCES})
find_package(json-c CONFIG)
target_link_libraries(${PROJECT_NAME} PRIVATE json-c::json-c)
then, I ran
cd build
cmake -DCMAKE_PREFIX_PATH=/home/<username>/base/project1/json-c-master ..
this populated the previously empty build directory.
then, I ran make
and I got the error that in project1.h, which #includes "json.h", the file "json.h" was not found.
How can I link json.h to project1.h?
I again appreciate your patience, I am a super noob with cmake and I've been pouring over their documentation and other SO posts to no avail.

How to add header file to /usr/include in Yocto

I am working with Linux built with Yocto. I would like to add to the image my app to /bin and some header file to /usr/include. I have no problem with adding the app to /bin, but I am not able to add the header file to my rootfs. The .h file is added to a proper package, but it is not copied to rootfs.
Here is my recipe:
bindir = "${localdir}/bin"
incldir = "${localdir}/usr/include"
FILESEXTRAPATHS_prepend := "${THISDIR}/files/:"
SRC_URI = "file://My_app_dir/* \
\
"
S = "${WORKDIR}"
FILES_${PN} += "${incldir}/*"
do_compile() {
cd My_app_dir/src
make
}
do_install() {
install -d ${D}${bindir}
cp "${S}/My_app_dir/src/my_app" "${D}${bindir}/my_app"
install -d ${D}${incldir}
cp "${S}/My_app_dir/some_lib.h" "${D}${incldir}/some_lib.h"
}
After building the image, the include file exists in /build/tmp/work/<machine>/<my_app>/image/usr/include.
Do you have any idea why I cannot add .h file to /usr/include in rootfs? Thank you in advance for any help.
The header files (among other files like pkgconfig and shared library symlinks) are not added to the main package (say foo), but to the development package (e.g. foo-dev). This is called package split and you can learn more in the Package Splitting of the official documentation. The development packages (and BTW also the debug foo-dbg) are not installed by default.
But please be aware that adding the development package may pull other dependencies (because of various runtime dependencies) and files (there are other files in the development package).
Please note that your line FILES_${PN} += "${incldir}/*" has no effect, as the files in $includedir (i.e. FILES_${PN}-dev) are split before the FILES_${PN} are processed. The order is defined in the variable PACKAGES (check the official documentation).
BTW, there are minor things in the recipe which you can update (unrelated to your question though):
You can use location of standard system paths in the respective variables bindir, includedir etc.
install is preferred over the cp in do_install.
The line FILESEXTRAPATHS_prepend := "${THISDIR}/files/:" is needed only in bbappends. The files directory inside the recipe's directory is in the standard search path of files (among other paths like ${PN} etc.).

ndk-build of static lib - why is it building other files?

I have a project structure as follows. All I want to do is build a static library with SQLite source but for some reason when I run ndk-build, it builds other source too - as if it is including Android.mk files in other locations.
jni/SQLite
jni/SQLite/Android.mk (the only .mk file that I want to build)
jni/TT
jni/Application.mk
jni/Android.mk (for building everything such as SDL2)
TT is a symbolic link to /work/TT which contains a number of cross-platform source files including SQLite, SDL2 and other source.
/work/TT
/work/TT/SQLite
/work/TT/SQLite/sqlite3.c
/work/TT/SDL2
..
Here is jni/SQLite/Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
TT_PATH := /work/TT
SRC_SQLITE := $(TT_PATH)/SQLite/sqlite3.c
LOCAL_C_INCLUDES += $(NDK_APP_PROJECT_PATH)/jni
LOCAL_MODULE := SQLite
LOCAL_SRC_FILES := $(SRC_SQLITE)
include $(BUILD_STATIC_LIBRARY)
Why are other files being built? What do I need to do to build SQLite only?
At the command prompt I am in the following folder:
jni/SQLite
I run ndk-build (same folder as the Android.mk contents above)
I expect to see sqlite3.c being the only file compiled. But no, I see all of the SDL2 project files being built..
Once all files have been compiled, if I run ndk-build again I see this:
MacbookPro:SQLite admin$ ndk-build
[armeabi-v7a] Install : libSDL2.so => libs/armeabi-v7a/libSDL2.so
[armeabi-v7a] Install : libmain.so => libs/armeabi-v7a/libmain.so
This clearly shows modules SDL2 and main being built.. but why?
Perhaps I am supposed to use:
ndk-build -f Android.mk
..to build my one and only desired Android.mk instead of automatically having my jni folder searched/built?
When I do that I get the following error but at least it looks as though it is trying to run the one specific Android.mk:
MacbookPro:SQLite admin$ ndk-build -f Android.mk
Android NDK: Trying to define local module 'SQLite' in Android.mk.
Android NDK: But this module was already defined by /Work/TT/android-TT/app/src/main/jni/SQLite/Android.mk.
/Android/android-ndk-r9d/build/core/build-module.mk:34: *** Android NDK: Aborting. . Stop.
My Application.mk is as follows but this is not present in the SQLite folder where I run ndk-build, this is the jni/Application.mk:
# Uncomment this if you're using STL in your project
# See CPLUSPLUS-SUPPORT.html in the NDK documentation for more information
APP_STL := gnustl_static
APP_PLATFORM := android-14
APP_ABI := armeabi-v7a
UPDATE: I tried:
ndk-build -d -f Android.mk
..and the debug output shows that the SDL2/Android.mk and other .mk files are still being called. How do I stop this recursive behaviour so it only builds the Android.mk in the current folder?
This is a snippet of the debug output that I see:
Reading makefile `/Work/TT/android-TT/app/src/main/jni/SDL/Android.mk' (search path) (no ~ expansion)...
Reading makefile `/Work/TT/android-TT/app/src/main/obj/local/armeabi-v7a/objs/main/SQLite/sqlite3.o.d' (search path) (don't care) (no ~ expansion)...
The answer to my problem is to do this:
ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk
This will build the current folder Android.mk as required.

NDK - Android Java with native (JNI) C++ code build issue

I am using a mix of Java and native JNI C++ code for an android project, using NDK r8b, in Eclipse in OSX. I want to be able to use the regular C++ classes (map, string) in std namespace.
In the Android.mk file the following were added:
APP_STL := stlport_shared
Here I also tried static library. Refer to http://docs.huihoo.com/android/ndk/r5/CPLUSPLUS-SUPPORT.html
STLPORT_FORCE_REBUILD := true
Also tried removing the forced build.
In the C/C++ path and variables:
${NDKROOT}/sources/cxx-stl/stlport/stlport
"map" and "string" headers were included in the .cpp file. I am able to use std::string and std::map. The assistant picks up on them. When searching for the definition (F3 in eclipse) the header file is shown, i.e. resolved. Also, the outline shows the "string" and "map" header files and when double clicking them it also brings the headers to the forefront.
However, the build doesn't pick them up. I get the following:
> ndk-build
> Gdbserver : [arm-linux-androideabi-4.6] libs/armeabi/gdbserver
> Gdbsetup : libs/armeabi/gdb.setup
> Gdbserver : [arm-linux-androideabi-4.6] libs/armeabi-v7a/gdbserver
> Gdbsetup : libs/armeabi-v7a/gdb.setup
> Compile++ arm : ImageTargets <= ImageTargets.cpp
> xxx/Project/Code/MyImageTarget/jni/ImageTargets.cpp:20:18: fatal error: string: No such file > or directory
> compilation terminated.
> make: *** [xxx/Project/Code/MyImageTarget/obj/local/armeabi/objs-> debug/ImageTargets/ImageTargets.o] Error 1
Has anyone any idea what else is there to try.
Use V=1 parameter on ndk-build command line. This will echo all executed commands, including compilation and link, with all their parameters that NDK build assigns.
In your case, the answer can be found without detailed build log:
In the Android.mk file the following were added:
APP_STL := stlport_shared
This is your mistake. The document you cited explains that this setting should go into Application.mk. This file is usually considered optional. Yes it is. Instead of creating this file, you can specify APP_STL on the command line:
ndk-build V=1 APP_STL=stlport_static
I don't know why and how Eclipse resolves #include <string> or map.

Building and using shared libraries with bjam

Using bjam on ubuntu, I am building a c++ shared library and trying to use it in an executable. I have to build as shared since it wont link as static (lots of undefined references arise). Thats fine.
Two related problems:
1) Using a heirarchy of Jamfiles, my exe project (testServerHub) has a dependency on the shared library (pythonManager). Here's the Jamfile for the exe:
echo "Compiling serverHub//test" ;
# declare project name
project serverHub//testServerHub
: build-dir ../_gcc/intermediate
;
# build unit-test using these source files, dependent libraries and settings
exe testServerHub
: # Source
..\\..\\..\\common\\0_8_1\\test\\runner.cpp
successfulTest.cpp
# Dependent libraries by path and project name
../controller/pythonManager//pythonManager
/boost//unit_test_framework
: # Settings
<link>shared
;
install ..\\bin : testServerHub ;
And here's my lib Jamfile:
echo "Compiling serverHub/controller//pythonManager" ;
# declare project name
project serverHub/controller//pythonManager
: requirements
<define>URTH_SERVERHUB
: build-dir ../../_gcc/intermediate
;
# build library using these source files and settings
lib pythonManager
: ../../../../common/0_8_1/controller/pythonManager/pythonManager.cpp
../../../../common/0_8_1/controller/pythonManager/cppInterfaceBase.cpp
cppInterfaceServerHub.cpp
/boost/python//boost_python
/user-config//python
: <link>shared
;
# copy and rename
install ../../lib : pythonManager ;
If I run 'bjam pythonManager' the pythonManager shared library is built and copied to my project lib folder (by the final install command). However if I run 'bjam test', both testServerHub and pythonManager are built, but the libpythonManager.so is not copied to the project lib folder - the install command doens't run!
2) Okay, so as a temporary workaround, I build libpythonManager.so first and then build testServerHub executable. Both compile and link. At runtime, the executable complains about not being able to find libpythonManager.so. Not a great surprise since the runtime linker doesn't know about my project lib folder. How do I tell it to look in a certain directory for shared libraries? or how do I install libpythonManager.so into /usr/local/lib if the install command has no effect on dependent library builds?
Thank you very much
Si
I think that you could use <install-dependencies>on in the exe Jamfile, like in
install ..\\bin : testServerHub : <install-dependencies>on <install-type>LIB ;
This will install all the libraries (LIB) on which the exe depends.
See eg http://www.boost.org/doc/tools/build/doc/html/bbv2/tasks/installing.html as a reference.

Resources