Execution failed for task ':app:externalNativeBuildDebug' Android.mk - android

I'm trying to run this project https://github.com/eyetrackingDB/GazeTrackingFramework
I installed Android Studio 2.3.3, with NDK 15.1.4119039, and Gradle version 3.3, and Android plugin version 2.3.3.
I have a problem in linking phase.
I got this message:
Error:FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:externalNativeBuildDebug'.
> Build command failed.
Error while executing process /Users/younghov/Library/Android/sdk/ndk-bundle/ndk-build with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/Users/younghov/AndroidStudioProjects/GazeTrackingFramework-master_7/app/src/main/jni/Android.mk NDK_APPLICATION_MK=/Users/younghov/AndroidStudioProjects/GazeTrackingFramework-master_7/app/src/main/jni/Application.mk APP_ABI=mips64 NDK_ALL_ABIS=mips64 NDK_DEBUG=1 APP_PLATFORM=android-21 NDK_OUT=/Users/younghov/AndroidStudioProjects/GazeTrackingFramework-master_7/app/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=/Users/younghov/AndroidStudioProjects/GazeTrackingFramework-master_7/app/build/intermediates/ndkBuild/debug/lib /Users/younghov/AndroidStudioProjects/GazeTrackingFramework-master_7/app/build/intermediates/ndkBuild/debug/obj/local/mips64/libeyetab_tracker.so}
Android NDK: WARNING:/Users/younghov/AndroidStudioProjects/GazeTrackingFramework-master_7/app/src/main/jni/Android.mk:eyetab_tracker: non-system libraries in linker flags: -lopencv_java
Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
Android NDK: current module
[mips64] Compile++ : eyetab_tracker <= eyetab_tracker.cpp
/bin/sh: /Users/younghov/Library/Android/sdk/ndk-bundle/toolchains/mips64el-linux-android-4.8/prebuilt/darwin-x86_64/bin/mips64el-linux-android-g++: No such file or directory
make: *** [/Users/younghov/AndroidStudioProjects/GazeTrackingFramework-master_7/app/build/intermediates/ndkBuild/debug/obj/local/mips64/objs-debug/eyetab_tracker/eyetab_tracker.o] Error 127
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Here is my Android.mk file:
#Set the local path to the JNI folder
LOCAL_PATH := $(call my-dir)
# INCLUDE OPENCV AND OWN MODULE
include $(CLEAR_VARS)
include /Users/younghov/Downloads/OpenCV-2.4.9-android-sdk/sdk/native/jni/OpenCV.mk
LOCAL_MODULE := eyetab_tracker
LOCAL_SRC_FILES := eyetab_tracker.cpp EyeTabTracker/GazeSettingsEyeTab.cpp EyeTabTracker/GazeTrackerEyeTab.cpp EyeTabTracker/src_eyetab/erase_specular.cpp EyeTabTracker/src_eyetab/eye_center_isophotes.cpp EyeTabTracker/src_eyetab/eye_center_combined.cpp EyeTabTracker/src_eyetab/fit_ellipse.cpp EyeTabTracker/src_eyetab/utils.cpp EyeTabTracker/src_eyetab/gaze_geometry.cpp EyeTabTracker/src_eyetab/gaze_smoothing.cpp EyeTabTracker/src_eyetab/get_poss_limb_pts.cpp EyeTabTracker/src_eyetab/get_eyelids.cpp EyeTabTracker/src_eyetab/gaze_system.cpp EyeTabTracker/src_eyetab/eye_detect.cpp EyeTabTracker/src_eyelike/findEyeCenter.cpp EyeTabTracker/src_eyelike/helpers.cpp
LOCAL_LDLIBS += -lm -llog -landroid LOCAL_CFLAGS += -std=c++11 -I/Users/younghov/Downloads/tbb2017_20170604oss/include
include $(BUILD_SHARED_LIBRARY)
# Add prebuilt libavcodec
include $(CLEAR_VARS)
LOCAL_MODULE := libavcodec
LOCAL_SRC_FILES := prebuilt/libavcodec.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libavdevice
include $(CLEAR_VARS)
LOCAL_MODULE := libavdevice
LOCAL_SRC_FILES := prebuilt/libavdevice.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libavfilter
include $(CLEAR_VARS)
LOCAL_MODULE := libavfilter
LOCAL_SRC_FILES := prebuilt/libavfilter.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libavformat
include $(CLEAR_VARS)
LOCAL_MODULE := libavformat
LOCAL_SRC_FILES := prebuilt/libavformat.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libavutil
include $(CLEAR_VARS)
LOCAL_MODULE := libavutil
LOCAL_SRC_FILES := prebuilt/libavutil.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libffmpeg
include $(CLEAR_VARS)
LOCAL_MODULE := libffmpeg
LOCAL_SRC_FILES := prebuilt/libffmpeg.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libjniavcodec
include $(CLEAR_VARS)
LOCAL_MODULE := libjniavcodec
LOCAL_SRC_FILES := prebuilt/libjniavcodec.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libjniavdevice
include $(CLEAR_VARS)
LOCAL_MODULE := libjniavdevice
LOCAL_SRC_FILES := prebuilt/libjniavdevice.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libjniavfilter
include $(CLEAR_VARS)
LOCAL_MODULE := libjniavfilter
LOCAL_SRC_FILES := prebuilt/libjniavfilter.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libjniavformat
include $(CLEAR_VARS)
LOCAL_MODULE := libjniavformat
LOCAL_SRC_FILES := prebuilt/libjniavformat.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libjniavutil
include $(CLEAR_VARS)
LOCAL_MODULE := libjniavutil
LOCAL_SRC_FILES := prebuilt/libjniavutil.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libjnicvkernels
include $(CLEAR_VARS)
LOCAL_MODULE := libjnicvkernels
LOCAL_SRC_FILES := prebuilt/libjnicvkernels.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libjniopencv_calib3d
include $(CLEAR_VARS)
LOCAL_MODULE := libjniopencv_calib3d
LOCAL_SRC_FILES := prebuilt/libjniopencv_calib3d.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libjniopencv_contrib
include $(CLEAR_VARS)
LOCAL_MODULE := libjniopencv_contrib
LOCAL_SRC_FILES := prebuilt/libjniopencv_contrib.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libjniopencv_core
include $(CLEAR_VARS)
LOCAL_MODULE := libjniopencv_core
LOCAL_SRC_FILES := prebuilt/libjniopencv_core.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libjniopencv_features2d
include $(CLEAR_VARS)
LOCAL_MODULE := libjniopencv_features2d
LOCAL_SRC_FILES := prebuilt/libjniopencv_features2d.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libjniopencv_flann
include $(CLEAR_VARS)
LOCAL_MODULE := libjniopencv_flann
LOCAL_SRC_FILES := prebuilt/libjniopencv_flann.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libjniopencv_highgui
include $(CLEAR_VARS)
LOCAL_MODULE := libjniopencv_highgui
LOCAL_SRC_FILES := prebuilt/libjniopencv_highgui.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libjniopencv_imgproc
include $(CLEAR_VARS)
LOCAL_MODULE := libjniopencv_imgproc
LOCAL_SRC_FILES := prebuilt/libjniopencv_imgproc.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libjniopencv_legacy
include $(CLEAR_VARS)
LOCAL_MODULE := libjniopencv_legacy
LOCAL_SRC_FILES := prebuilt/libjniopencv_legacy.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libjniopencv_ml
include $(CLEAR_VARS)
LOCAL_MODULE := libjniopencv_ml
LOCAL_SRC_FILES := prebuilt/libjniopencv_ml.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libjniopencv_nonfree
include $(CLEAR_VARS)
LOCAL_MODULE := libjniopencv_nonfree
LOCAL_SRC_FILES := prebuilt/libjniopencv_nonfree.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libjniopencv_objdetect
include $(CLEAR_VARS)
LOCAL_MODULE := libjniopencv_objdetect
LOCAL_SRC_FILES := prebuilt/libjniopencv_objdetect.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libjniopencv_photo
include $(CLEAR_VARS)
LOCAL_MODULE := libjniopencv_photo
LOCAL_SRC_FILES := prebuilt/libjniopencv_photo.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libjniopencv_stitching
include $(CLEAR_VARS)
LOCAL_MODULE := libjniopencv_stitching
LOCAL_SRC_FILES := prebuilt/libjniopencv_stitching.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libjniopencv_superres
include $(CLEAR_VARS)
LOCAL_MODULE := libjniopencv_superres
LOCAL_SRC_FILES := prebuilt/libjniopencv_superres.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libjniopencv_video
include $(CLEAR_VARS)
LOCAL_MODULE := libjniopencv_video
LOCAL_SRC_FILES := prebuilt/libjniopencv_video.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libjniopencv_videostab
include $(CLEAR_VARS)
LOCAL_MODULE := libjniopencv_videostab
LOCAL_SRC_FILES := prebuilt/libjniopencv_videostab.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libjnipostproc
include $(CLEAR_VARS)
LOCAL_MODULE := libjnipostproc
LOCAL_SRC_FILES := prebuilt/libjnipostproc.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libjniswresample
include $(CLEAR_VARS)
LOCAL_MODULE := libjniswresample
LOCAL_SRC_FILES := prebuilt/libjniswresample.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libjniswscale
include $(CLEAR_VARS)
LOCAL_MODULE := libjniswscale
LOCAL_SRC_FILES := prebuilt/libjniswscale.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libopencv_calib3d
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_calib3d
LOCAL_SRC_FILES := prebuilt/libopencv_calib3d.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libopencv_contrib
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_contrib
LOCAL_SRC_FILES := prebuilt/libopencv_contrib.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libopencv_core
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_core
LOCAL_SRC_FILES := prebuilt/libopencv_core.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libopencv_features2d
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_features2d
LOCAL_SRC_FILES := prebuilt/libopencv_features2d.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libopencv_flann
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_flann
LOCAL_SRC_FILES := prebuilt/libopencv_flann.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libopencv_gpu
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_gpu
LOCAL_SRC_FILES := prebuilt/libopencv_gpu.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libopencv_highgui
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_highgui
LOCAL_SRC_FILES := prebuilt/libopencv_highgui.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libopencv_imgproc
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_imgproc
LOCAL_SRC_FILES := prebuilt/libopencv_imgproc.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libopencv_legacy
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_legacy
LOCAL_SRC_FILES := prebuilt/libopencv_legacy.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libopencv_ml
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_ml
LOCAL_SRC_FILES := prebuilt/libopencv_ml.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libopencv_nonfree
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_nonfree
LOCAL_SRC_FILES := prebuilt/libopencv_nonfree.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libopencv_objdetect
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_objdetect
LOCAL_SRC_FILES := prebuilt/libopencv_objdetect.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libopencv_photo
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_photo
LOCAL_SRC_FILES := prebuilt/libopencv_photo.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libopencv_stitching
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_stitching
LOCAL_SRC_FILES := prebuilt/libopencv_stitching.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libopencv_superres
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_superres
LOCAL_SRC_FILES := prebuilt/libopencv_superres.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libopencv_video
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_video
LOCAL_SRC_FILES := prebuilt/libopencv_video.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libopencv_videostab
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_videostab
LOCAL_SRC_FILES := prebuilt/libopencv_videostab.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libpostproc
include $(CLEAR_VARS)
LOCAL_MODULE := libpostproc
LOCAL_SRC_FILES := prebuilt/libpostproc.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libswresample
include $(CLEAR_VARS)
LOCAL_MODULE := libswresample
LOCAL_SRC_FILES := prebuilt/libswresample.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libswscale
include $(CLEAR_VARS)
LOCAL_MODULE := libswscale
LOCAL_SRC_FILES := prebuilt/libswscale.so
include $(PREBUILT_SHARED_LIBRARY)
# Add prebuilt libtbb
include $(CLEAR_VARS)
LOCAL_MODULE := libtbb
LOCAL_SRC_FILES := prebuilt/libtbb.so
include $(PREBUILT_SHARED_LIBRARY)
Am i missing something or have some incompatible issue with version?

Related

Android JNI native library not packaged to apk

While transforming my project from eclipse to AS.
I got a fatal error which caused by "the lib not found " problem.
My project contains jni codes,compiled by ndk build system and managed by the "Android.mk" file.
After transformed I found that two of the libraries(.so) was not packaged into the apk file while other libraries are packaged correctly.
Here is part of the content of "Android.mk" file,all libraries are packaged but "curl" and "jsqlite".The two files do exist in the right path.Is there any suggestion,thks!!
LOCAL_PATH := $(call my-dir)
MY_LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := skia
LOCAL_SRC_FILES := libs/$(TARGET_ARCH_ABI)/libskia.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := iconv
LOCAL_SRC_FILES := libs/$(TARGET_ARCH_ABI)/libiconv.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_EXPORT_LDLIBS :=
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := jsqlite
LOCAL_SRC_FILES := libs/$(TARGET_ARCH_ABI)/libjsqlite.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_EXPORT_LDLIBS := -lz
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := curl
LOCAL_SRC_FILES := libs/$(TARGET_ARCH_ABI)/libcurl.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_EXPORT_LDLIBS :=
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := gdal
LOCAL_SRC_FILES := libs/$(TARGET_ARCH_ABI)/libgdal.so
LOCAL_SHARED_LIBRARIES := jsqlite
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_EXPORT_LDLIBS := -lz
include $(PREBUILT_SHARED_LIBRARY)

How to use shared library without header files in Android?

I have a shared lib (ex. libcrypto.so), but don't have header files.
Can I use this lib in other module?
I tried to use LOCAL_EXPORT_C_INCLUDES to export header files, but It doesn't work.
This is prebuilt module:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libcrypto
LOCAL_SRC_FILES := prebuilt/$(TARGET_ARCH_ABI)/libcrypto.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)
And, this is module used libcrypto:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES += test.c # include "openssl/crypto.h"
LOCAL_C_INCLUDES += $(crypto_PATH)/include
LOCAL_SHARED_LIBRARIES += libcrypto
LOCAL_MODULE := libtest
LOCAL_MODULE_TAGS := optional
LOCAL_ARM_MODE := arm
LOCAL_PRELINK_MODULE := false
include $(BUILD_SHARED_LIBRARY)
This is libcrypto module (boringssl):
LOCAL_PATH := $(call my-dir)
# Target shared library
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := libcrypto
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/src/include
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk $(LOCAL_PATH)/crypto-sources.mk
LOCAL_SDK_VERSION := 9
LOCAL_CFLAGS += -fvisibility=hidden -DBORINGSSL_SHARED_LIBRARY -DBORINGSSL_IMPLEMENTATION -DOPENSSL_SMALL -Wno-unused-parameter
# sha256-armv4.S does not compile with clang.
LOCAL_CLANG_ASFLAGS_arm += -no-integrated-as
LOCAL_CLANG_ASFLAGS_arm64 += -march=armv8-a+crypto
include $(LOCAL_PATH)/crypto-sources.mk
include $(BUILD_SHARED_LIBRARY)
EDIT: Added boringssl module. I actually used #include "openssl/crypto.h" in test.c
Usually, you find crypto.h under include/openssl. So, in your case, either change the #include statement in test.c
#include "openssl/crypto.h"
Or (less recommended), edit
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include/openssl

NDK build error (error: linker command failed with exit code 1 (use -v to see invocation))

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.

libjpeg wont link with opencv on android

Android.mk
LOCAL_PATH:=$(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_core
LOCAL_SRC_FILES := $(LOCAL_PATH)/opencv_precompiled/libs/$(APP_ABI)/libopencv_core.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_calib3d
LOCAL_SRC_FILES := $(LOCAL_PATH)/opencv_precompiled/libs/$(APP_ABI)/libopencv_calib3d.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_videostab
LOCAL_SRC_FILES := $(LOCAL_PATH)/opencv_precompiled/libs/$(APP_ABI)/libopencv_videostab.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_videoio
LOCAL_SRC_FILES := $(LOCAL_PATH)/opencv_precompiled/libs/$(APP_ABI)/libopencv_videoio.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_video
LOCAL_SRC_FILES := $(LOCAL_PATH)/opencv_precompiled/libs/$(APP_ABI)/libopencv_video.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_shape
LOCAL_SRC_FILES := $(LOCAL_PATH)/opencv_precompiled/libs/$(APP_ABI)/libopencv_shape.a
include $(PREBUILT_STATIC_LIBRARY)
ifeq ($(APP_ABI),armeaby-v7a)
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_ts
LOCAL_SRC_FILES := $(LOCAL_PATH)/opencv_precompiled/libs/$(APP_ABI)/libopencv_ts.a
include $(PREBUILT_STATIC_LIBRARY)
endif
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_superres
LOCAL_SRC_FILES := $(LOCAL_PATH)/opencv_precompiled/libs/$(APP_ABI)/libopencv_superres.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_stitching
LOCAL_SRC_FILES := $(LOCAL_PATH)/opencv_precompiled/libs/$(APP_ABI)/libopencv_stitching.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_photo
LOCAL_SRC_FILES := $(LOCAL_PATH)/opencv_precompiled/libs/$(APP_ABI)/libopencv_photo.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_flann
LOCAL_SRC_FILES := $(LOCAL_PATH)/opencv_precompiled/libs/$(APP_ABI)/libopencv_flann.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_objdetect
LOCAL_SRC_FILES := $(LOCAL_PATH)/opencv_precompiled/libs/$(APP_ABI)/libopencv_objdetect.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_ml
LOCAL_SRC_FILES := $(LOCAL_PATH)/opencv_precompiled/libs/$(APP_ABI)/libopencv_ml.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_imgcodecs
LOCAL_SRC_FILES := $(LOCAL_PATH)/opencv_precompiled/libs/$(APP_ABI)/libopencv_imgcodecs.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_features2d
LOCAL_SRC_FILES := $(LOCAL_PATH)/opencv_precompiled/libs/$(APP_ABI)/libopencv_features2d.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_highgui
LOCAL_SRC_FILES := $(LOCAL_PATH)/opencv_precompiled/libs/$(APP_ABI)/libopencv_highgui.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libopencv_imgproc
LOCAL_SRC_FILES := $(LOCAL_PATH)/opencv_precompiled/libs/$(APP_ABI)/libopencv_imgproc.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libtbb
LOCAL_SRC_FILES := $(LOCAL_PATH)/opencv_precompiled/3rdparty/libs/$(APP_ABI)/libtbb.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libIlmImf
LOCAL_SRC_FILES := $(LOCAL_PATH)/opencv_precompiled/3rdparty/libs/$(APP_ABI)/libIlmImf.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := liblibjasper
LOCAL_SRC_FILES := $(LOCAL_PATH)/opencv_precompiled/3rdparty/libs/$(APP_ABI)/liblibjasper.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := liblibjpeg
LOCAL_SRC_FILES := $(LOCAL_PATH)/opencv_precompiled/3rdparty/libs/$(APP_ABI)/liblibjpeg.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := liblibpng
LOCAL_SRC_FILES := $(LOCAL_PATH)/opencv_precompiled/3rdparty/libs/$(APP_ABI)/liblibpng.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := liblibtiff
LOCAL_SRC_FILES := $(LOCAL_PATH)/opencv_precompiled/3rdparty/libs/$(APP_ABI)/liblibtiff.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := liblibwebp
LOCAL_SRC_FILES := $(LOCAL_PATH)/opencv_precompiled/3rdparty/libs/$(APP_ABI)/liblibwebp.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(LOCAL_PATH)/eigen\
$(LOCAL_PATH)/inc\
$(LOCAL_PATH)/opencv_precompiled/include\
LOCAL_MODULE:=blend
LOCAL_SRC_FILES:=$(LOCAL_PATH)/src/poisson_solver.cpp $(LOCAL_PATH)/src/clone.cpp $(LOCAL_PATH)/src/seamless_cloning.cpp
LOCAL_LDLIBS += -lz -llog -landroid -ldl -lm -ljnigraphics
LOCAL_STATIC_LIBRARIES := libopencv_shape libopencv_stitching libopencv_objdetect libopencv_superres libopencv_videostab libopencv_calib3d\
libopencv_features2d libopencv_highgui libopencv_videoio libopencv_imgcodecs libopencv_video libopencv_photo\
libopencv_ml libopencv_imgproc libopencv_flann libopencv_core\
liblibjpeg liblibwebp liblibpng liblibtiff liblibjasper libIlmImf libtbb\
ifeq ($(APP_ABI),armeaby-v7a)
LOCAL_LDLIBS += libopencv_ts
endif
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := cpu_info-jni
LOCAL_SRC_FILES := $(LOCAL_PATH)/src/utils.cpp
include $(BUILD_SHARED_LIBRARY)
Application.mk
NDK_TOOLCHAIN_VERSION := 4.9
APP_ABI := arm64-v8a
APP_CPPFLAGS += -std=c++11 -fexceptions
APP_STL := gnustl_static
This is the error i get:
/home/pedja/workspace/Projekat/android/src/main/jni/opencv_precompiled/libs/arm64-v8a/libopencv_imgcodecs.a(grfmt_jpeg.cpp.o): In function `cv::my_jpeg_load_dht(jpeg_decompress_struct*, unsigned char*, JHUFF_TBL**, JHUFF_TBL**) [clone .constprop.52]':
grfmt_jpeg.cpp:(.text.unlikely._ZN2cvL16my_jpeg_load_dhtEP22jpeg_decompress_structPhPP9JHUFF_TBLS5_.constprop.52+0x104): undefined reference to `jpeg_alloc_huff_table'
/home/pedja/workspace/Projekat/android/src/main/jni/opencv_precompiled/libs/arm64-v8a/libopencv_imgcodecs.a(grfmt_jpeg.cpp.o): In function `cv::JpegEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)':
Full error:
Error
To answer my own question.
For some reason, module name for local static libraries cannot be: "liblibjpeg" for example.
After renaming module liblibjpeg (and other libs that start with lib) to libjpeg it linked successfully.

including header files android jni

I am trying to use pjsip on android.. after ./configure-android and make dep and make commands, static libraries were generated 13 of them.
I used the include folder which is copied inside jni folder. The content of android.mk in jni folder is as follows:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libpj-arm-unknown-linux-androideabi
LOCAL_SRC_FILES := ../pjsip_lib/libpj-arm-unknown-linux-androideabi.a
LOCAL_MODULE := libpjlib-util-arm-unknown-linux-androideabi
LOCAL_SRC_FILES := ../pjsip_lib/libpjlib-util-arm-unknown-linux-androideabi.a
LOCAL_MODULE := libpjmedia-arm-unknown-linux-androideabi
LOCAL_SRC_FILES := ../voiper/pjsip_lib/libpjmedia-arm-unknown-linux-androideabi.a
LOCAL_MODULE := libpjmedia-audiodev-arm-unknown-linux-androideabi
LOCAL_SRC_FILES := ../pjsip_lib/libpjmedia-audiodev-arm-unknown-linux-androideabi.a
LOCAL_MODULE := libpjmedia-codec-arm-unknown-linux-androideabi
LOCAL_SRC_FILES := ../pjsip_lib/libpjmedia-codec-arm-unknown-linux-androideabi.a
LOCAL_MODULE := libpjmedia-videodev-arm-unknown-linux-androideabi
LOCAL_SRC_FILES := ../pjsip_lib/libpjmedia-videodev-arm-unknown-linux-androideabi.a
LOCAL_MODULE := libpjnath-arm-unknown-linux-androideabi
LOCAL_SRC_FILES := ../pjsip_lib/libpjnath-arm-unknown-linux-androideabi.a
LOCAL_MODULE := libpjsdp-arm-unknown-linux-androideabi
LOCAL_SRC_FILES := ../pjsip_lib/libpjsdp-arm-unknown-linux-androideabi.a
LOCAL_MODULE := libpjsip-arm-unknown-linux-androideabi
LOCAL_SRC_FILES := ../pjsip_lib/libpjsip-arm-unknown-linux-androideabi.a
LOCAL_MODULE := libpjsip-simple-arm-unknown-linux-androideabi
LOCAL_SRC_FILES := ../pjsip_lib/libpjsip-simple-arm-unknown-linux-androideabi.a
LOCAL_MODULE := libpjsip-ua-arm-unknown-linux-androideabi
LOCAL_SRC_FILES := ../pjsip_lib/libpjsip-ua-arm-unknown-linux-androideabi.a
LOCAL_MODULE := libpjsua2-arm-unknown-linux-androideabi
LOCAL_SRC_FILES := ../pjsip_lib/libpjsua2-arm-unknown-linux-androideabi.a
LOCAL_MODULE := libpjsua-arm-unknown-linux-androideabi
LOCAL_SRC_FILES := ../pjsip_lib/libpjsua-arm-unknown-linux-androideabi.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := dummy_pjsip_jni_module
LOCAL_SRC_FILES := dummy_pjsua.c
LOCAL_EXPORT_C_INCLUDES += ./include
LOCAL_C_INCLUDES += ./include
LOCAL_STATIC_LIBRARIES := libpj-arm-unknown-linux-androideabi libpjlib-util-arm-unknown-linux-androideabi libpjmedia-arm-unknown-linux-androideabi libpjmedia-audiodev-arm-unknown-linux-androideabi libpjmedia-codec-arm-unknown-linux-androideabi libpjmedia-videodev-arm-unknown-linux-androideabi libpjnath-arm-unknown-linux-androideabi libpjsdp-arm-unknown-linux-androideabi libpjsip-arm-unknown-linux-androideabi libpjsip-simple-arm-unknown-linux-androideabi libpjsip-ua-arm-unknown-linux-androideabi libpjsua2-arm-unknown-linux-androideabi libpjsua-arm-unknown-linux-androideabi
include $(BUILD_SHARED_LIBRARY)
I wrote a simple one line c file that only includes a header file inside include folder. Then i run ndk-build from the project directory and get no such file for the header file which is present inside the include folder. There is no application.mk.. What am i missing?
EDIT
the '.' represents the current directory.. "include" folder is inside jni folder
There are several issues here:
1) Each prebuilt static library should have its own module definition, i.e. your Android.mk should look like:
include $(CLEAR_VARS)
LOCAL_MODULE := libpj
LOCAL_SRC_FILES := libpj-arm-unknown-linux-androideabi.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libpjlib-util
LOCAL_SRC_FILES := libpjlib-util-arm-unknown-linux-androideabi.a
include $(PREBUILT_STATIC_LIBRARY)
... etc
Note that the module name doesn't have to be exactly the same as the file path, which makes things a little clearer for the rest.
2) That '.' will refer, at build time, to the current directory where you invoke ndk-build, you need to use $(LOCAL_PATH)/include instead to refer to the right include path (assuming your Android.mk is under jni/ too). I.e.:
include $(CLEAR_VARS)
LOCAL_MODULE := dummy_pjsip_jni_module
LOCAL_SRC_FILES := dummy_pjsua.c
LOCAL_EXPORT_C_INCLUDES += $(LOCAL_PATH)/include
LOCAL_C_INCLUDES += $(LOCAL_PATH)/include
LOCAL_STATIC_LIBRARIES := libpj libpjlib-util libpjmedia libpjmedia-audiodev \
libpjmedia-codec libpjmedia-videodev libpjnath \
libpjsdp libpjsip libpjsip-simple libpjsip-ua \
libpjsua2 libpjsua
include $(BUILD_SHARED_LIBRARY)

Categories

Resources