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)
Related
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>
This is my android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
FREETYPE_SRC_PATH :=
LOCAL_MODULE := freetype
LOCAL_CFLAGS := -DANDROID_NDK \
-DFT2_BUILD_LIBRARY=1
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include_all \
$(FREETYPE_SRC_PATH)include \
$(FREETYPE_SRC_PATH)src
LOCAL_SRC_FILES := \
$(FREETYPE_SRC_PATH)src/autofit/autofit.c \
$(FREETYPE_SRC_PATH)src/base/basepic.c \
$(FREETYPE_SRC_PATH)src/base/ftapi.c \
$(FREETYPE_SRC_PATH)src/base/ftbase.c \
LOCAL_LDLIBS := -ldl -llog
include $(BUILD_SHARED_LIBRARY)
And this is Application.mk:
APP_PLATFROM := android-20
APP_ABI := armeabi-v7a x86
After i hit ndk-build on the terminal Android Studio, i got an error message:
make: *** No rule to make target '/app/src/main/jni/src/base/basepic.c
I've checked android.mk:
$(FREETYPE_SRC_PATH)src/autofit/autofit.c \
$(FREETYPE_SRC_PATH)src/base/basepic.c \
there is no whitespace. But still got an error.
Gradle model version=6.0.1, NDK version=21.1.6352462
I need to ndk-build without problem.. any i can do to solve this issue?
In your android.mk file you have FREETYPE_SRC_PATH empty. I guess it must be assigned as /app/src/main/jni/.
I have never built curl with Android.
Pre-requisites : I am using Android Studio 2.1.2
I am using NDK , non-experimental way
I have Source code of the curl-7.49.1 library inside my jni folder in curlLib directory
ExtLibCurl is folder/directory inside my application jni folder, which has source code downloaded from
https://android.googlesource.com/platform/external/curl/+/e6f2b03027b5feb92b30f5d47801ec3fabe9fd95
Can check Android.mk for cURL and other files there.
Updating the files according to the comments in the question.
Following is my Android.mk file
JNI_DIR := $(call my-dir)
LOCAL_PATH:= $(JNI_DIR)
include $(CLEAR_VARS)
include $(LOCAL_PATH)/ExtLibCurl/Android.mk
# Build main library as shared library.
LOCAL_PATH := $(JNI_DIR)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_C_INCLUDES += $(LOCAL_PATH)/ExtLibCurl/include/curl
LOCAL_C_INCLUDES += $(LOCAL_PATH)/ExtLibCurl/lib
FILE_LIST += $(wildcard $(LOCAL_PATH)/ExtLibCurl/src/*.c)
LOCAL_MODULE := ndksampleapp
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)
LOCAL_STATIC_LIBRARIES := ExtLibCurl
include $(BUILD_SHARED_LIBRARY)
Application.mk
APP_ABI := all
APP_STL := gnustl_static
APP_CFLAGS += -std=gnu++11
APP_OPTIM := debug
LOCAL_CPP_FEATURES += exceptions
NDK_TOOLCHAIN_VERSION := 4.9
Is my way of building curl's Android.mk is correct?
when I do ndk-build in src\main path I am getting following error
[arm64-v8a] Compile : ndksampleapp <= curlutil.c
cc1.exe: warning: command line option '-std=gnu++11' is valid for C++/ObjC++ but not for C
In file included from jni/ExtLibCurl/lib/strdup.h:24:0,
from jni/ExtLibCurl/src/setup.h:206,
from jni/ExtLibCurl/src/curlutil.c:23:
jni/ExtLibCurl/lib/setup.h:120:28: fatal error: curl/curlbuild.h: No such file or directory
#include <curl/curlbuild.h>
^
compilation terminated.
make: *** [obj/local/arm64-v8a/objs-debug/ndksampleapp/ExtLibCurl/src/curlutil.o] Error 1
If I remove FILE_LIST += $(wildcard $(LOCAL_PATH)/ExtLibCurl/src/*.c) no cURL files are getting build.
yours Android.mk file should look like this:
JNI_DIR := $(call my-dir)
LOCAL_PATH:= $(JNI_DIR)
include $(CLEAR_VARS)
include $(LOCAL_PATH)/ExtLibCurl/Android.mk
# Build main library as shared library.
LOCAL_PATH := $(JNI_DIR)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES += $(LOCAL_PATH)/ExtLibCurl/include
LOCAL_C_INCLUDES += $(LOCAL_PATH)/ExtLibCurl/lib
# !!! place list of YOUR sources to this variable !!!
FILE_LIST += $(wildcard $(LOCAL_PATH)/src/*.c)
LOCAL_MODULE := ndksampleapp
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)
LOCAL_STATIC_LIBRARIES := libcurl
LOCAL_LDLIBS += -lz
include $(BUILD_SHARED_LIBRARY)
name of the module don't need to match its directory name.
From ExtLibCurl/Android.mk you must uncomment the BUILD_STATIC_LIBRARY part, and you can also remove all part with creating executable curl (lines 74+), that is the file will looks like this:
# Google Android makefile for curl and libcurl
#
# Place the curl source (including this makefile) into external/curl/ in the
# Android source tree. Then build them with 'make curl' or just 'make libcurl'
# from the Android root. Tested with Android 1.5
#
# Note: you must first create a curl_config.h file by running configure in the
# Android environment. The only way I've found to do this is tricky. Perform a
# normal Android build with libcurl in the source tree, providing the target
# "showcommands" to make. The build will eventually fail (because curl_config.h
# doesn't exist yet), but the compiler commands used to build curl will be
# shown. Now, from the external/curl/ directory, run curl's normal configure
# command with flags that match what Android itself uses. This will mean
# putting the compiler directory into the PATH, putting the -I, -isystem and
# -D options into CPPFLAGS, putting the -m, -f, -O and -nostdlib options into
# CFLAGS, and putting the -Wl, -L and -l options into LIBS, along with the path
# to the files libgcc.a, crtbegin_dynamic.o, and ccrtend_android.o. Remember
# that the paths must be absolute since you will not be running configure from
# the same directory as the Android make. The normal cross-compiler options
# must also be set.
#
# The end result will be a configure command that looks something like this
# (the environment variable A is set to the Android root path):
#
# A=`realpath ../..` && \
# PATH="$A/prebuilt/linux-x86/toolchain/arm-eabi-X/bin:$PATH" \
# ./configure --host=arm-linux CC=arm-eabi-gcc \
# CPPFLAGS="-I $A/system/core/include ..." \
# CFLAGS="-fno-exceptions -Wno-multichar ..." \
# LIB="$A/prebuilt/linux-x86/toolchain/arm-eabi-X/lib/gcc/arm-eabi/X\
# /interwork/libgcc.a ..." \
#
# Dan Fandrich
# September 2009
LOCAL_PATH:= $(call my-dir)
common_CFLAGS := -Wpointer-arith -Wwrite-strings -Wunused -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wno-long-long -Wfloat-equal -Wno-multichar -Wsign-compare -Wno-format-nonliteral -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wno-system-headers -DHAVE_CONFIG_H
#########################
# Build the libcurl library
include $(CLEAR_VARS)
include $(LOCAL_PATH)/lib/Makefile.inc
CURL_HEADERS := \
curlbuild.h \
curl.h \
curlrules.h \
curlver.h \
easy.h \
mprintf.h \
multi.h \
stdcheaders.h \
typecheck-gcc.h \
types.h
LOCAL_SRC_FILES := $(addprefix lib/,$(CSOURCES))
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include \
external/openssl/include \
external/zlib
LOCAL_CFLAGS += $(common_CFLAGS)
LOCAL_COPY_HEADERS_TO := libcurl/curl
LOCAL_COPY_HEADERS := $(addprefix include/curl/,$(CURL_HEADERS))
#LOCAL_SHARED_LIBRARIES := libz
LOCAL_MODULE:= libcurl
include $(BUILD_STATIC_LIBRARY)
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.
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.