How to compile ZBar to work on x64 Android device - android

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.

Related

How to include AIDL-generated headers in native code in AOSP?

I have a native module under /devices:
- module
-- aidl
--- com
---- my
----- package
------ IMyInterface.aidl
-- Android.mk
-- Proxy.h
-- Proxy.cpp
I want to use binder in this module. My Android.mk:
LOCAL_PATH := $(call my-dir)
$(call emugl-begin-shared-library,libMyModule)
LOCAL_AIDL_INCLUDES := $(LOCAL_PATH)/aidl
LOCAL_SRC_FILES := \
aidl/com/my/package/IMyInterface.aidl \
Proxy.cpp \
LOCAL_HEADER_LIBRARIES := libbinder_headers \
libhidlbase_impl_internal \
libbase
LOCAL_SHARED_LIBRARIES := \
libbinder \
libutils \
liblog \
libcutils
$(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
$(call emugl-import,libOpenglCodecCommon$(GOLDFISH_OPENGL_LIB_SUFFIX))
$(call emugl-end-module)
When I'm building it, it generates C++ headers, but they are located in the intermediates directory only:
$ ls out/target/product/emulator_x86_64/obj/SHARED_LIBRARIES/libMyModule_intermediates/aidl-generated/include/com/my/package:
BnMyInterface.h BpMyInterface.h IMyInterface.h
How should I include them in my Proxy.cpp? If I just add #include "IMyInterface.h", build system doesn't see it: fatal error: 'IMyInterface.h' file not found
You may have to include it like #include <com/my/package/BnMyInterface.h>

How do you find an Android module by name in AOSP?

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

Building mdadm tool for android platform

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)

Compiling C++11 sources for Android NDK

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).

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
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.

Categories

Resources