I'm trying to include a fingerprint module. i placed all the .c and .h files in a new directory under /external/ and created an Android.mk file as
########## libdpfpdd ############
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ldpfpdd
LOCAL_SRC_FILES := libdpfpdd.so
include $(PREBUILT_SHARED_LIBRARY)
########### libdpfj ##############
include $(CLEAR_VARS)
LOCAL_MODULE := ldpfj
LOCAL_SRC_FILES := libdpfj.so
include $(PREBUILT_SHARED_LIBRARY)
######### fingerprint ############
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := fingerprint
LOCAL_SRC_FILES := \
enrollment.c helpers.c identification.c \
menu.c sample.c selection.c verification.c
LOCAL_SHARED_LIBRARIES += ldpfpdd ldpfj
include $(BUILD_EXECUTABLE)
after this i tried to do cross compilation as
make TARGET_PRODUCT=am335xevm_sk -j8 OMAPES=4.x
and got the error as
make: *** No rule to make target `out/target/product/am335xevm_sk/obj/lib/ldpfpdd.so', needed by `out/target/product/am335xevm_sk/obj/EXECUTABLES/fingerprint_intermediates/LINKED/fingerprint'. Stop.
make: *** Waiting for unfinished jobs....
Related
I'm struggling to get a module to compile on Android. It references an already existing shared library -- that I only have the .so and .h files.
My current Android.mk looks like this:
LOCAL_PATH:= $(call my-dir)
EXEC_ARCH := armeabi-v7a
local_vendorlib_c_includes := $(LOCAL_PATH)/VENDORLIB/include
# VENDORLIBWrapper library
include $(CLEAR_VARS)
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_SRC_FILES := mylib.cpp
LOCAL_MODULE:= libvendorwrapper
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/soundfx
LOCAL_LDLIBS := -L$(LOCAL_PATH)/DPS/$(EXEC_ARCH)/
LOCAL_C_INCLUDES := \
$(call include-path-for, graphics corecg) \
$(call include-path-for, audio-effects) \
$(local_dps_c_includes)
LOCAL_CPPFLAGS += -O2 -Wno-unused-parameter
#--verbose
LOCAL_SHARED_LIBRARIES := \
libcutils \
libdl \
libVendorLib
#LOCAL_PREBUILT_LIBS += libVendorLib
LOCAL_REQUIRED_MODULES := libVendorLib
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE := libVendorLib
LOCAL_SRC_FILES := $(LOCAL_PATH)/VendorLib/$(EXEC_ARCH)/libVendorLib.so
LOCAL_MODULE_TAGS := debug
LOCAL_EXPORT_C_INCLUDES := $(local_vendorlib_c_includes)
include $(PREBUILT_SHARED_LIBRARY)
include $(call all-makefiles-under,$(LOCAL_PATH))
And I am getting the error below:
> ninja: error:
> 'out/target/product/generic/obj/lib/libVendorLib.so.toc', needed by
> 'out/target/product/generic/obj/SHARED_LIBRARIES/libvendorwrapper_intermediates/LINKED/libvendorwrapper.so', missing and no known rule to make it make: *** [ninja_wrapper] Error 1
> make: Leaving directory `/home/donatoaz/WORKING_DIRECTORY'
>
> #### make failed to build some targets (23 seconds) ####
I was able to finally build it by making the following changes
I was able to build it making the following changes:
include $(CLEAR_VARS)
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE := libVendorLib
LOCAL_SRC_FILES := libVendorLib.so # <== Moved the prebuilt lib to root / -- oddly enough, when it was in a subfolder, make would not find it.
LOCAL_MODULE_TAGS := debug
LOCAL_EXPORT_C_INCLUDES := $(local_vendorlib_c_includes)
include $(BUILD_PREBUILT) # <== changed this from PREBUILT_SHARED_LIBRARY
Now I get:
make completed successfully (21 seconds)
Application.mk
APP_STL := gnustl_static
APP_ABI := all
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libz
LOCAL_SRC_FILES := ../prebuild/libz.a
LOCAL_EXPORT_C_INCLUDES := ../prebuild/include/
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libssl
LOCAL_SRC_FILES := ../prebuild/libssl.a
LOCAL_EXPORT_C_INCLUDES := ../prebuild/include
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libcrypto
LOCAL_SRC_FILES := ../prebuild/libcrypto.a
LOCAL_EXPORT_C_INCLUDES := ../prebuild/include
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libjson-c
LOCAL_SRC_FILES := ../prebuild/libjson-c.a
LOCAL_EXPORT_C_INCLUDES := ../prebuild/include
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libcurl
LOCAL_SRC_FILES := ../prebuild/include/libcurlall/$(TARGET_ARCH_ABI)/libcurl.a
LOCAL_EXPORT_C_INCLUDES := ../prebuild/include
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := curl-ndk
LOCAL_SRC_FILES := ../cpp/curl-http.cpp
LOCAL_STATIC_LIBRARIES := libcurl libssl libcrypto libz libjson-c
LOCAL_LDLIBS := -lz -llog -ljnigraphics
include $(BUILD_SHARED_LIBRARY)
clean project and I'm trying to cross compile NDK then show given below error:
/Volumes/Work/Android/Projects/app/src/main/jni/../prebuild/libz.a: error adding symbols: File in wrong format
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [/Volumes/Work/Android/Projects/app/src/main/obj/local/arm64-v8a/libcurl-ndk.so] Error 1
Its working on 32 bits fine but 64 bit its show error
Thanks in advance
You're using one prebuilt for all ABIs. You need one prebuilt for each ABI you target. The typical way to write a prebuilt module is like this:
include $(CLEAR_VARS)
LOCAL_MODULE := libz
LOCAL_SRC_FILES := ../prebuild/$(TARGET_ARCH_ABI)/libz.a
LOCAL_EXPORT_C_INCLUDES := ../prebuild/include/
include $(PREBUILT_STATIC_LIBRARY)
Then you can have prebuild/armeabi-v7a/libz.a, prebuild/arm64-v8a/libz.a, etc. Disable ABIs you don't want to build for (or don't have prebuilts for) using APP_ABI in your Application.mk.
I am trying to use some c shared libraries in my android application.
The project structure is like:
project
|
|---app->main.cpp, Android.mk
|
|---lib->|->Android.mk
|
|---include----|
| |---mylib->a.h, b.h ...
|
|---libs-> libX.so, libY.so, libZ.so
In the main.cpp, I use the header files like:
#include <mylib/a.h>
#include <mylib/b.h>
In the /project/app/Android.mk, I have
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := my_application
LOCAL_SHARED_LIBRARIES := the_libX_1_0_0 the_libY_1_0_0 the_libZ_0_0_9
LOCAL_SRC_FILES := main.cpp
include $(BUILD_SHARED_LIBRARY)
In the /project/lib/Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := the_libX_1_0_0
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_SRC_FILES := $(LOCAL_PATH)/libs/libX.so
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := the_libY_1_0_0
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_SRC_FILES := $(LOCAL_PATH)/libs/libY.so
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := the_libZ_0_0_9
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_SRC_FILES := $(LOCAL_PATH)/libs/libZ.so
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
include $(BUILD_SHARED_LIBRARY)
[The build error]
When I try to make the application, the error I had:
including ./Android.mk ...
build/core/binary.mk:1345: *** project/lib/Android.mk: the_libX_1_0_0: Unused source files: project/lib/libs/the_libX_1_0_0.so.
build/core/ninja.mk:155: recipe for target 'out/build-aosp_arm.ninja' failed
make: *** [out/build-aosp_arm.ninja] Error 1
AOSP environment:
PLATFORM_VERSION := 6.0.1
PLATFORM_SDK_VERSION := 23
PLATFORM_JACK_MIN_SDK_VERSION := 24
Development environment:
Ubuntu 16.04 LTS
GCC 5.4
A bit more background about the question:
Actually, the library libX, libY and libZ are libcrypto.so, libssl.so and libc.so. Google uses a shrunk version of OpenSSL, I am working on an application requires the OpenSSL. So I am trying to use pre-built OpenSSL libraries here.
References:
https://developer.android.com/ndk/guides/prebuilts.html#dm
Android NDK/JNI: Building a shared library that depends on other shared libraries
http://www.scriptscoop3.com/t/84e1c84496bc/android-difference-between-local-export-c-includes-and-local-c-includes.html
I have some problem.
I use ndk-build but I can't make library *.so.
--------------------------------- Error ---------------------------------
nathaniel#Nathaniel-MSI /work/workspace/HealthCare $ ndk-build
make: *** No rule to make target `jni/jni/src/filterData.c', needed by
`obj/local/armeabi/objs/HealthCare/jni/src/filterData.o'. Stop.
Under the my Android.mk source, help me please
--------------------------------- Android.mk ---------------------------------
LOCAL_PATH := $(call my-dir)
SRCS := $(wildcard $(LOCAL_PATH)/src/*.c)
include $(CLEAR_VARS)
LOCAL_MODULE := HealthCare
LOCAL_SRC_FILES := $(SRCS)
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
LOCAL_SRC_FILES := $(SRCS:$(LOCAL_PATH)/%=%)
EDITED
LOCAL_C_INCLUDES := $(LOCAL_PATH)/src
I am trying to use a pre built library within my project...its name is libfreeimage.so...
I am not able to build it properly using the NDK-build....
The error log has been pasted here...
please help me in this regard...
flock#QS57:~/Desktop/android-imagefilter-ndk$ /home/flock/ANDROID/android-ndk-r8/ndk-build
Prebuilt : libfreeimage.so <= jni/
Install : libfreeimage.so => libs/armeabi/libfreeimage.so
/home/flock/ANDROID/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-strip: Unable to recognise the format of the input file `./libs/armeabi/libfreeimage.so'
make: *** [libs/armeabi/libfreeimage.so] Error 1
make: *** Deleting file libs/armeabi/libfreeimage.so
flock#QS57:~/Desktop/android-imagefilter-ndk$
My android.mk file-
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libfreeimage
LOCAL_SRC_FILES := libfreeimage.a
include $(PREBUILT_SHARED_LIBRARY)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := imageprocessing
LOCAL_SRC_FILES := imageprocessing.c
LOCAL_SHARED_LIBRARIES := libfreeimage
LOCAL_LDLIBS := -lm -llog -ljnigraphics
include $(BUILD_SHARED_LIBRARY)
You need to use
include ($BUILD_STATIC_LIBRARY)
instead of
include ($BUILD_SHARED_LIBRARY)
This will give you the desired .a file, not the .so.