I am working with Android+NDK+OpenCV.
I keep getting the following build error
Android NDK: Check that ../../OpenCV-2.4.10-android-sdk/sdk/native/jni/../libs/arm64-v8a/libopencv_java.so exists or that its path is correct
../../android-ndk-r10d/build/core/prebuilt-library.mk:45: *** Android NDK: Aborting . Stop.
My Application.mk file is:
APP_PLATFORM := android-8
APP_ABI := armeabi armeabi-v7a arm64-v8a x86 x86_64 mips mips64
APP_OPTIM := debug
NDK_DEBUG := 1
NDK_TOOLCHAIN_VERSION := 4.6
APP_STL := gnustl_shared
APP_CPPFLAGS := -fexceptions -frtti
And my Android.mk file is:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
OPENCV_INSTALL_MODULES := on
include ../../OpenCV-2.4.10-android-sdk/sdk/native/jni/OpenCV.mk
LOCAL_MODULE := document_scanner
LOCAL_SRC_FILES := jni_part.cpp
LOCAL_C_INCLUDES :=../../OpenCV-2.4.10-android-sdk/sdk/native/jni/include
LOCAL_LDLIBS += -llog
include $(BUILD_SHARED_LIBRARY)
Try to move include ../../OpenCV-2.4.10-android-sdk/sdk/native/jni/OpenCV.mk below include $(CLEAR_VARS)
Related
Iam new to android ndk , i have created basic app with android ndk and i have already created all mk files ( android.mk and application.mk ) how to solve the abi error
enter code here LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
#opencv
OPENCVROOT:= C:\OpenCV-OpenCV 3.2-android-sdk
OPENCV_CAMERA_MODULES:=on
OPENCV_INSTALL_MODULES:=on
OPENCV_LIB_TYPE:=SHARED
include ${OPENCVROOT}/sdk/native/jni/OpenCV.mk
LOCAL_SRC_FILES := com_example_working_new.cpp
LOCAL_LDLIBS += -llog
LOCAL_MODULE := MyLibs
include $(BUILD_SHARED_LIBRARY)
my Application.mk file
enter code here APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi-v7a
APP_PLATFORM := android-16
the simple way is to make all APP_Abi for different platforms and emulators edit this in your application.mk file.
enter code here
APP_ABI :=all
Here is my Android.mk
LOCAL_PATH := $(call my-dir)
LOCAL_STATIC_LIBRARIES = -lboost_system ...
include $(CLEAR_VARS)
LOCAL_MODULE := AVL
LOCAL_MODULE_FILENAME:= libAVL
LOCAL_SRC_FILES := AVL.cpp
LOCAL_CFLAGS += -I$(LOCAL_PATH)/boost/include/boost-1_55
LOCAL_CPPFLAGS += -fexceptions
LOCAL_CPPFLAGS += -frtti
include $(BUILD_SHARED_LIBRARY)
include $(BUILD_STATIC_LIBRARY)
Application.mk
APP_ABI := all
APP_STL := stlport_static
Error:
Android NDK: jni/Android.mk:AVL: LOCAL_MODULE_FILENAME must not contain a file extension
/home/manevbg/Documents/android-sdks/android-ndk-r10/build/core/build-static-library.mk:29: *** Android NDK: Aborting . Stop.
Any idea how to build shared library?
PP: Using eclipse.
Remove the LOCAL_MODULE_FILENAME:= libAVL. The build system will correctly prefix the library with 'lib' for you.
Environment
android-ndk-r10c
VisualGDB
Windows x64
Use-case 1
ADB Cmdline executable ( no Java / APK ) is consist of several C++ files
Executable is compiled having "APP_STL := gnustl_static" at Application.mk
Executable is successfully compiled and running
Use-case 2
The ADB tool of Use-case 1 is split into two separate projects
A static library encapsulating general purpose functionality
The ADB Tool minus the functionality moved out to the static lib
Executable & static Lib are compiled having "APP_STL := gnustl_static" at Application.mk
ADB Exe is compiled having LOCAL_LDLIBS := -L$(PATH_TO_STATIC_LIB) -lstaticlib
Compilation fail with "undefined reference to `std::terminate()'" Linker error
Problem at hand
When compiling all CPP files as one project all goes fine, no linker error.
When spiting the logic into a thin executable and a staticlib (that the executable is linked against ) I get an "undefined reference to `std::terminate()'" Linker error.
It seems to me as if "gnustl_static" is not linked with the executable although "APP_STL := gnustl_static" is specified...
What am I missing here? Is there any way to force 'gnustl_static' to link ?
The make files for reference:
Makefile where all files are part of the same executable (WORKING)
Application.mk
APP_STL := gnustl_static
APP_ABI := all
APP_CFLAGS := -std=gnu++11
APP_CPPFLAGS := -std=gnu++11
NDK_TOOLCHAIN_VERSION := 4.9
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ScreenCapSvc
LOCAL_SRC_FILES := ScreenCapSvc.cpp SnapshotController.cpp SimpleTCPStream.cpp SocketsServer.cpp uuids.cpp
LOCAL_C_INCLUDES :=
LOCAL_STATIC_LIBRARIES :=
LOCAL_SHARED_LIBRARIES :=
LOCAL_LDLIBS := -llog
LOCAL_CFLAGS :=
LOCAL_CPPFLAGS :=
LOCAL_LDFLAGS :=
COMMON_SRC_FILES := $(LOCAL_SRC_FILES)
include $(BUILD_EXECUTABLE)
Makefiles where files are split into a static lib and executable that links against the lib
(NOT WORKING)
Executable Application.mk
APP_STL := gnustl_static
APP_ABI := all
APP_CFLAGS := -std=gnu++11
APP_CPPFLAGS := -std=gnu++11
NDK_TOOLCHAIN_VERSION := 4.9
Executable Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ScreenCapSvc
LOCAL_SRC_FILES := ScreenCapSvc.cpp SnapshotController.cpp
LOCAL_C_INCLUDES :=
LOCAL_STATIC_LIBRARIES :=
LOCAL_SHARED_LIBRARIES :=
LOCAL_LDLIBS := -llog -L$(PATH_TO_STATIC_LIB) -lCollections_statis
LOCAL_CFLAGS :=
LOCAL_CPPFLAGS :=
LOCAL_LDFLAGS :=
COMMON_SRC_FILES := $(LOCAL_SRC_FILES)
include $(BUILD_EXECUTABLE)
Static Lib Application.mk
APP_STL := gnustl_static
APP_ABI := all
APP_CFLAGS := -std=gnu++11
APP_CPPFLAGS := -std=gnu++11
NDK_TOOLCHAIN_VERSION := 4.9
APP_MODULES := Collections-static Collections-shared
Static Lib Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := Collections-shared
LOCAL_SRC_FILES := SimpleTCPStream.cpp SocketsServer.cpp uuids.cpp
LOCAL_C_INCLUDES :=
LOCAL_STATIC_LIBRARIES :=
LOCAL_SHARED_LIBRARIES :=
LOCAL_LDLIBS := -llog
LOCAL_CFLAGS :=
LOCAL_CPPFLAGS :=
LOCAL_LDFLAGS :=
COMMON_SRC_FILES := $(LOCAL_SRC_FILES)
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := Collections-static
LOCAL_SRC_FILES := $(COMMON_SRC_FILES)
include $(BUILD_STATIC_LIBRARY)
This isn't a bug in the NDK build system, but it is an issue with how you are using it.
If you run ndk-build V=1, you see the actual commands that it tries to execute, and you'd see that it already tries to link in gnustl_static, but it links it in before linking in your own static library. The linker only tries libraries in the order they are specified on the linker command line, which means that it won't try to use the earlier specified gnustl_static library to resolve undefined references from a later library.
The correct solution here is to not use LOCAL_LDLIBS for forcing linking to a static library, but use the NDK provided infrastructure for linking to static libraries. That is, change your executable Android.mk like this:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ScreenCapSvc
LOCAL_SRC_FILES := ScreenCapSvc.cpp SnapshotController.cpp
LOCAL_STATIC_LIBRARIES := Collections_static
LOCAL_LDLIBS := -llog
include $(BUILD_EXECUTABLE)
include $(CLEAR_VARS)
LOCAL_MODULE := Collections_static
LOCAL_SRC_FILES := $(PATH_TO_STATIC_LIB)/libCollections_static.a
include $(PREBUILT_STATIC_LIBRARY)
This way, you include the static library into the build of the executable in the same way regardless if the static library is built as part of the same build, or is a prebuilt library.
This syntax also allows you to add LOCAL_EXPORT_C_INCLUDES in the section for the static library, to add the right include path when building the executable, without having to manually add it to section for the executable.
It appears that indeed although "APP_STL := gnustl_static" is strictly specified at Application.mk of the Executable it is not really linked, to force gnustl_static to link I have added the following to LOCAL_LDLIBS of Android.mk
LOCAL_LDLIBS += -L$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/$(TARGET_ARCH_ABI) -lgnustl_static
Seems to me like a bug in the NDK build system...
I am trying to use ndk-build to use native code for audio processing from Little Endian in an Android application (I don't have JNI yet).
When I executed ndk-build in jni dir I got ($USER_PATH is path to directory on my computer):
Android NDK: WARNING: Rebuilding libc++ libraries from sources!
Android NDK: You might want to use $NDK/build/tools/build-cxx-stl.sh --stl=libc++
Android NDK: in order to build prebuilt versions to speed up your builds!
Android NDK: ERROR:$USER_PATH/android-ndk-r10/sources/android/compiler-rt/Android.mk:compiler_rt_shared: LOCAL_SRC_FILES points to a missing file
Android NDK: $USER_PATH/Android/android-ndk-r10/sources/android/compiler-rt/libs/armeabi/libcompiler_rt_shared.so exists or that its path is correct
$USER_PATH/android-ndk-r10/build/core/prebuilt-library.mk:45: *** Android NDK: Aborting . Stop.
I saw that is because of PREBUILT_STATIC_LIBRARY which points to missing files.
How can I solve this?
Directory structure:
There are .mk files:
Android.mk
MY_LOCAL_PATH := $(call my-dir)
ifndef LE_SDK_PATH
LE_SDK_PATH := $(call my-dir)
endif
include $(MY_LOCAL_PATH)/le_audioio.mk
include $(MY_LOCAL_PATH)/le_utility.mk
LOCAL_PATH := ${MY_LOCAL_PATH}
include $(CLEAR_VARS)
LOCAL_MODULE := little-endian
LOCAL_STATIC_LIBRARIES := le_audioio le_utility
include $(BUILD_SHARED_LIBRARY)
Application.mk
APP_PLATFORM := android-14
APP_STL := c++_static
APP_ABI := armeabi armeabi-v7a x86
APP_OPTIM := release
APP_CFLAGS += -g
NDK_TOOLCHAIN_VERSION := clang
le_audioio.mk
ifndef LE_SDK_PATH
LE_SDK_PATH := $(call my-dir)
endif
LOCAL_PATH:= $(LE_SDK_PATH)
include $(CLEAR_VARS)
LOCAL_MODULE := le_audioio
LOCAL_EXPORT_C_INCLUDES := $(abspath $(LE_SDK_PATH)/include)
LOCAL_EXPORT_LDLIBS += -lOpenSLES
ifeq ($(TARGET_ARCH_ABI),x86)
LOCAL_SRC_FILES := libs/development/libAudioIO_Android_x86-32_SSSE3.a
else
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
LOCAL_ARM_NEON := true
LOCAL_SRC_FILES := libs/development/libAudioIO_Android_ARMv7a_NEON.a
else
LOCAL_SRC_FILES := libs/release/libAudioIO_Android_ARMv6_VFP2.a
endif
endif
include $(PREBUILT_STATIC_LIBRARY)
le_utilityio.mk
ifndef LE_SDK_PATH
LE_SDK_PATH := $(call my-dir)
endif
LOCAL_PATH:= $(LE_SDK_PATH)
include $(CLEAR_VARS)
LOCAL_MODULE := le_utility
LOCAL_EXPORT_C_INCLUDES := $(abspath $(LE_SDK_PATH)/include)
LOCAL_EXPORT_LDLIBS += -landroid -llog
ifeq ($(TARGET_ARCH_ABI),x86)
LOCAL_SRC_FILES := libs/development/libUtility_Android_x86-32_SSSE3.a
else
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
LOCAL_ARM_NEON := true
LOCAL_SRC_FILES := libs/development/libUtility_Android_ARMv7a_NEON.a
else
LOCAL_SRC_FILES := libs/release/libUtility_Android_ARMv6_VFP2.a
LOCAL_EXPORT_LDLIBS += -latomic
endif
endif
include $(PREBUILT_STATIC_LIBRARY)
Try this a new solution by Google for audio application.
Cant build with using gnustl_static. Got:
'abs' was not declared in this scope
And when trying to build with stlport I cant use c++11 methods.
Here is my Application.mk:
APP_ABI := armeabi-v7a
APP_STL := gnustl_static
APP_CPPFLAGS += -std=c++11 -w
APP_PLATFORM := android-19
APP_OPTIM := release
And Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ModuleName
LOCAL_LDLIBS := -lm -llog -landroid
LOCAL_C_INCLUDES := .......
LOCAL_SRC_FILES += .......
include $(BUILD_SHARED_LIBRARY)