Errors building tesseract Android tools - android
I am trying to build Tesseract for android and have been getting issues. I am following a tutorial where the following instructions have been given to build Tesseract.
cd <project-directory>
curl -O https://tesseract-ocr.googlecode.com/files/tesseract-ocr-3.02.02.tar.gz
curl -O http://leptonica.googlecode.com/files/leptonica-1.69.tar.gz
tar -zxvf tesseract-ocr-3.02.02.tar.gz
tar -zxvf leptonica-1.69.tar.gz
rm -f tesseract-ocr-3.02.02.tar.gz
rm -f leptonica-1.69.tar.gz
mv tesseract-3.02.02 jni/com_googlecode_tesseract_android/src
mv leptonica-1.69 jni/com_googlecode_leptonica_android/src
ndk-build -j8
android update project --target 1 --path .
ant debug (release)
Firstly there is no path at (i.e no src directory)
jni/com_googlecode_tesseract_android/src
jni/com_googlecode_leptonica_android/src
So I am not too sure where they should go, so I left them in their extracted folder.
Also when running
ndk-build -j8
I get the following errors
In file included from jni/com_googlecode_leptonica_android/pixa.cpp:17:0:
jni/com_googlecode_leptonica_android/common.h:22:24: fatal error: allheaders.h: No such file or directory
#include <allheaders.h>
^
In file included from jni/com_googlecode_leptonica_android/pix.cpp:17:0:
jni/com_googlecode_leptonica_android/common.h:22:24: fatal error: allheaders.h: No such file or directory
#include <allheaders.h>
^
compilation terminated.
In file included from jni/com_googlecode_leptonica_android/readfile.cpp:17:0:
jni/com_googlecode_leptonica_android/common.h:22:24: fatal error: allheaders.h: No such file or directory
#include <allheaders.h>
^
compilation terminated.
compilation terminated.
In file included from jni/com_googlecode_leptonica_android/jni.cpp:17:0:
jni/com_googlecode_leptonica_android/common.h:22:24: fatal error: allheaders.h: No such file or directory
#include <allheaders.h>
^
compilation terminated.
In file included from jni/com_googlecode_leptonica_android/utilities.cpp:17:0:
jni/com_googlecode_leptonica_android/common.h:22:24: fatal error: allheaders.h: No such file or directory
#include <allheaders.h>
^
compilation terminated.
In file included from jni/com_googlecode_leptonica_android/writefile.cpp:17:0:
jni/com_googlecode_leptonica_android/common.h:22:24: fatal error: allheaders.h: No such file or directory
#include <allheaders.h>
^
compilation terminated.
In file included from jni/com_googlecode_leptonica_android/box.cpp:17:0:
jni/com_googlecode_leptonica_android/common.h:22:24: fatal error: allheaders.h: No such file or directory
#include <allheaders.h>
^
compilation terminated.
make: *** [obj/local/armeabi/objs/lept/pix.o] Error 1
make: *** Waiting for unfinished jobs....
make: *** [obj/local/armeabi/objs/lept/readfile.o] Error 1
make: *** [obj/local/armeabi/objs/lept/utilities.o] Error 1
make: *** [obj/local/armeabi/objs/lept/jni.o] Error 1
make: *** [obj/local/armeabi/objs/lept/writefile.o] Error 1
make: *** [obj/local/armeabi/objs/lept/pixa.o] Error 1
make: *** [obj/local/armeabi/objs/lept/box.o] Error 1
UPDATE:
Interestingly after starting again
mv tesseract-ocr jni/com_googlecode_tesseract_android/src
mv leptonica-1.69 jni/com_googlecode_leptonica_android/src
are working.
During building I get the following errors:
jni/com_googlecode_tesseract_android/src/dict/permdawg.cpp: In member function 'void tesseract::Dict::go_deeper_dawg_fxn(const char*, const BLOB_CHOICE_LIST_VECTOR&, int, const CHAR_FRAGMENT_INFO*, bool, WERD_CHOICE*, float*, float*, WERD_CHOICE*, int*, void*)':
jni/com_googlecode_tesseract_android/src/dict/permdawg.cpp:208:62: error: format not a string literal and no format arguments [-Werror=format-security]
fprintf(output_ambig_words_file_, word_str.string());
^
cc1plus: some warnings being treated as errors
make: *** [obj/local/armeabi/objs/tess/src/dict/permdawg.o] Error 1
make: *** Waiting for unfinished jobs....
I also had the same problem.
These are the steps I followed:
Downloaded the tesseract_android_tools project from github.com/alanv/tesseract-android-tools
Extracted it and moved to tesseract-android-tools via Terminal
curl -O https://tesseract-ocr.googlecode.com/files/tesseract-ocr-3.02.02.tar.gz
curl -O http://leptonica.googlecode.com/files/leptonica-1.69.tar.gz
tar -zxvf tesseract-ocr-3.02.02.tar.gz
tar -zxvf leptonica-1.69.tar.gz
rm -f tesseract-ocr-3.02.02.tar.gz
rm -f leptonica-1.69.tar.gz
mv tesseract-3.02.02 jni/com_googlecode_tesseract_android/src
mv leptonica-1.69 jni/com_googlecode_leptonica_android/src
I tried running android-ndk-r9 but it kept on throwing the error jni/com_googlecode_tesseract_android/src/dict/permdawg.cpp:208:62: error: format not a string literal and no format arguments [-Werror=format-security]
cc1plus.exe: some warnings being treated as errors
I modified jni/com_googlecode_tesseract_android/src/dict/permdawg.cpp line 208 from fprintf(output_ambig_words_file_, word_str.string()); to fprintf(output_ambig_words_file_, "%s", word_str.string());
I tried running android.bat update project -p . but kept on complaining that Error: The project either has no target set or the target is invalid.
Please provide a --target to the 'android.bat update' command.
I provided the target by first running android list targets to get the targets I have and then android update project -t 7 -p . since 7 was my preferred target
That worked.
Sorry for the late reply
Related
ubuntu 15.10 64bit build Android source 5.0 version
How can I fix this problem?When I was building the Android source of 5.0 with 'make -j4', it was causing a problem. This is the error log: Install: out/host/linux-x86/bin/acp Yacc: aidl <= frameworks/base/tools/aidl/aidl_language_y.y prebuilts/misc/linux-x86/bison/bison -d -o out/host/linux-x86/obj32/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp frameworks/base/tools/aidl/aidl_language_y.y Lex: aidl <= frameworks/base/tools/aidl/aidl_language_l.l logtags: out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/content/EventLogTags.java <= frameworks/base/core/java/android/content/EventLogTags.logtags prebuilts/misc/linux-x86/bison/bison: m4 子进程失败 build/core/binary.mk:539: recipe for target 'out/host/linux-x86/obj32/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp' failed make: *** [out/host/linux-x86/obj32/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp] Error 1 make: *** 正在等待未完成的任务.... frameworks/base/tools/aidl/aidl_language_l.l:55: warning, 无法匹配规则 flex-2.5.39: fatal internal error, exec of /usr/bin/m4 failed build/core/binary.mk:576: recipe for target 'out/host/linux-x86/obj32/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp' failed make: *** [out/host/linux-x86/obj32/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp] Error 1 make: *** Deleting file 'out/host/linux-x86/obj32/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp' logtags: out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/speech/tts/EventLogTags.java <= frameworks/base/core/java/android/speech/tts/EventLogTags.logtags
In my case, I get similar error when build Marshmallow 6.0.1_r1 in Ubuntu 18.04. If you get similar errors like this: build/core/binary.mk:646: recipe for target 'out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp' failed make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp] Aborted (core dumped) Look at the line carefully, it's a core dumped, so I use coredumpctl list, navigate to the end of list with G, then figure out the core dump executed path (right column) is prebuilts/misc/linux-x86/flex/flex-2.5.39 And the PREBUILT file shows: xb#dnxb:~/my_android_src/prebuilts/misc/linux-x86/flex$ cat PREBUILT The objects in this prebuilt directory can be rebuilt using the source archive hosted at http://sourceforge.net/projects/flex/files/ Commands: ./configure make CFLAGS="-static" LDFLAGS="-static" # (Disregard the errors at the end of the build) rm flex make CFLAGS="-static" LDFLAGS="-static" flex # Copy the linker command line, replace it with static libm.a gcc -static -static -o flex ccl.o dfa.o ecs.o scanflags.o gen.o main.o misc.o nfa.o parse.o scan.o skel.o sym.o tblcmp.o yylex.o options.o scanopt.o buf.o tables.o tables_shared.o filter.o regex.o /usr/lib/x86_64-linux-gnu/libm.a xb#dnxb:~/my_android_src/prebuilts/misc/linux-x86/flex$ That's it, the first 2 lines said that you probably need to rebuild yourself if something went wrong since this flex-2.5.39 binary is prebuilt in another platform. So simply untar the flex-2.5.39.tar.gz of this directory, go to the extracted flex-2.5.39 directory, then follows the PREBUILT instruction above. In short, you need to do the following steps: cd <ANDROID_TREE_DIR>/prebuilts/misc/linux-x86/flex tar -zxvf flex-2.5.39.tar.gz cd flex-2.5.39 make CFLAGS="-static" LDFLAGS="-static" rm flex make CFLAGS="-static" LDFLAGS="-static" flex /bin/bash ./libtool --tag=CC --mode=link gcc -static -static -o flex ccl.o dfa.o ecs.o scanflags.o gen.o main.o misc.o nfa.o parse.o scan.o skel.o sym.o tblcmp.o yylex.o options.o scanopt.o buf.o tables.o tables_shared.o filter.o regex.o lib/libcompat.la /usr/lib/x86_64-linux-gnu/libm.a cd .. cp flex-2.5.39/flex . mv flex flex-2.5.39 ls -la flex-2.5.39 #### <<- YOUR new generated file flex-2.5.39.tar.gz MODULE_LICENSE_BSD_LIKE NOTICE PREBUILT Now try to do make <module> -j4 again, no longer abort on such error. p/s: Alternative way will be LANG=C make pm -j4 if you see something like LC_* error message. p/s2: I also need symlink ld as below to fixed 'out/host/linux-x86/obj/lib/libart.so' failed and error: unsupported reloc 42: xb#dnxb:~/my_android_src$ cp prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8//x86_64-linux/bin/ld ../ld_bk #backup android source's ld first xb#dnxb:~/my_android_src$ rm prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8//x86_64-linux/bin/ld #remove android source's ld xb#dnxb:~/my_android_src$ ln -s /usr/bin/ld.gold prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8//x86_64-linux/bin/ld #create symlink for android source's ld to system's ld.gold
Check carefully you have all the required packages installed https://source.android.com/source/initializing.html
How to compile and execute MPICH2 for Android
For cross compiling MPICH2 for Android. I found the reference here http://hex.ro/wp/projects/personal-cloud-computing/compiling-mpich2-for-android-and-running-on-two-phones/ and here www.scientificbulletin.upb.ro/rev_docs_arhiva/fullffc_583765. I did following BuildRoot Used Build Root (buildroot-2016.02) for cross compiling ARM toolchain Target options : Target Architecture as ARM little endian Target binary format as ELF Selected Toolchain as Buildroot toolchain (Internal) Kernel headers as 3.12.x C library as uClibc After this make command was run. MPICH2 mpich-3.2.tar.gz was extracted and following commands were executed 1. $ export PATH=/home/mpiuser/CrossBuild/buildroot-2016.02/output/host/usr/bin:$PATH 2. $ sudo ./configure --prefix=/home/mpiuser/CrossBuild/arm-mpich-install --disable-fortran CC=/home/mpiuser/CrossBuild/buildroot-2016.02/output/host/usr/bin/arm-linux-gcc --host=arm-linux After this make was run for mpich-3.2, and during compilation following error was thrown : GEN lib/libmpi.la CXX src/binding/cxx/initcxx.lo CXXLD lib/libmpicxx.la lib/.libs/libmpi.so: error adding symbols: File in wrong format collect2: error: ld returned 1 exit status make[2]: *** [lib/libmpicxx.la] Error 1 make[2]: Leaving directory `/home/mpiuser/CrossBuild/mpich-3.2' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/mpiuser/CrossBuild/mpich-3.2' make: *** [all] Error 2 Request to please help. Thanks
Error: file not found: arch/arm/boot/compressed/piggy.lzo
I am trying to build android project Getting below error even after setting correct path for toolchains /bin/sh: lzop: not found AS arch/arm/boot/compressed/piggy.lzo.o arch/arm/boot/compressed/piggy.lzo.S: Assembler messages: arch/arm/boot/compressed/piggy.lzo.S:4: Error: file not found: arch/arm/boot/compressed/piggy.lzo make[2]: *** [arch/arm/boot/compressed/piggy.lzo.o] Error 1 make[1]: *** [arch/arm/boot/compressed/vmlinux] Error 2 make: *** [zImage] Error 2 make: Leaving directory `/home/user/workspace/android/kernel/exynos54xx' build: error: build-kernel failed and die !!!
Here is a solution if you're using Ubuntu: $ sudo apt-get install lzop or look for the lzop package of you OS.
Compiling muPDF lib in Eclipse "cannot unlink `NUL': Invalid argument Android NDK" Error
I'm trying to compile the muPDF lib in Eclipse on Windows 7. I'm following these steps. On this step Build the native code libraries: ~/src/mupdf/platform/android $ ndk-build I'm getting this error. Qadir Hussain#GENETECH042 ~/mupdf/platform/android (master) $ ndk-build "C:/Program Files (x86)/Git/bin/rm.exe": cannot unlink `NUL': Invalid argument Android NDK: WARNING:jni/Android.mk:mupdfcore: LOCAL_LDLIBS is always ignored fo r static libraries 0 [main] rm 4244 stdio_init: couldn't make stderr distinct from stdout 0 [main] rm 2876 stdio_init: couldn't make stderr distinct from stdout 0 [main] rm 4832 stdio_init: couldn't make stderr distinct from stdout [armeabi-v7a] Compile thumb : mupdf <= mupdf.c ./obj/convert-dependencies.sh: line 6: syntax error: unexpected end of file e:/android-ndk/android-ndk-r9d/build/core/build-binary.mk:391: recipe for target 'obj/local/armeabi-v7a/objs/mupdf/mupdf.o' failed make: *** [obj/local/armeabi-v7a/objs/mupdf/mupdf.o] Error 2 make: *** Deleting file 'obj/local/armeabi-v7a/objs/mupdf/mupdf.o' Also when I launch this command it creates a file NUL in my ..platform/android directory, the file has no extension and couldn't be deleted or renamed.
How to prevent cmake adding "compatibility_version" for gcc?
I'm pretty new to cmake and i'm trying to cross-compile libftdi for ARM Linux (Android). Why cmake adds "-compatibility_version" to gcc command-line which leads to error: /softdev/arm-toolchain/bin/arm-linux-androideabi-gcc -O2 -g -DNDEBUG -dynamiclib -Wl,-headerpad_max_install_names -L/softdev/arm-libs/lib -compatibility_version 2.0.0 -current_version 2.0.0 -o libftdi1.2.0.0.dylib -install_name /Users/asmirnov/Documents/dev/src/libftdi-1.0/src/libftdi1.2.dylib CMakeFiles/ftdi1.dir/ftdi.c.o CMakeFiles/ftdi1.dir/ftdi_stream.c.o /usr/local/lib/libusb-1.0.dylib arm-linux-androideabi-gcc: error: 2.0.0: No such file or directory arm-linux-androideabi-gcc: error: 2.0.0: No such file or directory arm-linux-androideabi-gcc: error: /Users/asmirnov/Documents/dev/src/libftdi-1.0/src/libftdi1.2.dylib: No such file or directory arm-linux-androideabi-gcc: error: unrecognized option '-compatibility_version' arm-linux-androideabi-gcc: error: unrecognized option '-current_version' make[2]: *** [src/libftdi1.2.0.0.dylib] Error 1 make[1]: *** [src/CMakeFiles/ftdi1.dir/all] Error 2 make: *** [all] Error 2 Since i can't find "compatibility_version" command-line parameter in supported by gcc parameters list is it cmake error or cmake configuration problem? UPDATE: problem #1 solved (hacked) i've solved the problem by commenting the next lines in ../Modules/Platforms/Darwin.cmake: # 4ntoine (fix for libftdi compilation using cmake) #set(CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ") #set(CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ") #set(CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}") #set(CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}") # ... # 4ntoine (fix for libftdi build using cmake) #if(NOT XCODE) # Enable shared library versioning. This flag is not actually referenced # but the fact that the setting exists will cause the generators to support # soname computation. # set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-install_name") #endif() I know it's not good especially when you are not sure what you're doing ;) Now i have another problem #2: cd /Users/asmirnov/Documents/dev/src/libftdi-1.0/build/src && /usr/local/Cellar/cmake/2.8.11.1/bin/cmake -E cmake_link_script CMakeFiles/ftdi1.dir/link.txt --verbose=1 /softdev/arm-toolchain/bin/arm-linux-androideabi-gcc -O2 -g -DNDEBUG -dynamiclib -Wl,-headerpad_max_install_names -L/softdev/arm-libs/lib -o libftdi1.dylib CMakeFiles/ftdi1.dir/ftdi.c.o CMakeFiles/ftdi1.dir/ftdi_stream.c.o /softdev/arm-libs/lib/libusb-1.0.so /softdev/arm-toolchain/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: /softdev/arm-toolchain/bin/../sysroot/usr/lib/crtbegin_dynamic.o: in function _start:crtbrand.c(.text+0x78): error: undefined reference to 'main' collect2: ld returned 1 exit status make[2]: *** [src/libftdi1.dylib] Error 1 make[1]: *** [src/CMakeFiles/ftdi1.dir/all] Error 2 make: *** [all] Error 2