No such .h file or directory(Android, Cocos2d-x, NDK) - android

I am using an open source library to implement the facebook share features with cocos2d-x.
However, when I integrated with android, I have a problem that cannot load the .h file in "jni/screw" folder.
screenshot:
the file structure:
here it is my android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d/external)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d/cocos)
LOCAL_MODULE := cocos2dcpp_shared
LOCAL_MODULE_FILENAME := libcocos2dcpp
CPP_FILES := $(shell find $(LOCAL_PATH)/../../Classes -name *.cpp)
LOCAL_SRC_FILES := hellocpp/main.cpp
LOCAL_SRC_FILES += $(CPP_FILES:$(LOCAL_PATH)/%=%)
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes \
# _COCOS_HEADER_ANDROID_BEGIN
# _COCOS_HEADER_ANDROID_END
LOCAL_STATIC_LIBRARIES := cocos2dx_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_store_static
LOCAL_WHOLE_STATIC_LIBRARIES += screw_static
# _COCOS_LIB_ANDROID_BEGIN
# _COCOS_LIB_ANDROID_END
include $(BUILD_SHARED_LIBRARY)
$(call import-module,.)
$(call import-module, extensions/cocos2dx-store)
# _COCOS_LIB_IMPORT_ANDROID_BEGIN
# _COCOS_LIB_IMPORT_ANDROID_END
How to solve? Thanks!
reference library screw:
https://github.com/hiepnd/Screw

Related

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

Building audio processing Little Endian SDK with NDK

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.

import local submodules in android jni project

I'm try to create android jni project with structure.
I want create static library test_module and include it to main shared library monitor
jni directory contain
jni
|-> MonitorPreview.cpp
|-> Processor.cpp
|-> Android.mk
|-> test_module
|-> IModule.cpp
|-> TestModule.cpp
|-> Android.mk
where jni/Android.mk
LOCAL_PATH := $(call my-dir)
MY_ROOT := $(LOCAL_PATH)
include $(call all-subdir-makefiles)
include $(CLEAR_VARS)
LOCAL_PATH := $(MY_ROOT)
LOCAL_MODULE := monitor
LOCAL_C_INCLUDES := $(LOCAL_PATH)/test_module
LOCAL_SRC_FILES := MonitorPreview.cpp \
Processor.cpp
LOCAL_STATIC_LIBRARIES := test_module
LOCAL_LDLIBS := -llog -landroid
include $(BUILD_SHARED_LIBRARY)
$(call import-module, test_module)
jni/test_module/Android.mk
LOCAL_PATH := $(call my-dir)
$(info local path = $(LOCAL_PATH))
include $(CLEAR_VARS)
LOCAL_MODULE := test_module
LOCAL_SRC_FILES := IModule.cpp \
TestModule.cpp
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
include $(PREBUILD_STATIC_LIBRARY)
ndk-build fail with error
/home/pavel/android_dev/android-ndk-r8e/ndk-build all
local path = jni/test_module
SharedLibrary : libmonitor.so
/home/pavel/android_dev/android-ndk-r8e/toolchains/arm-linux-androideabi- 4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux- androideabi/bin/ld: ./obj/local/armeabi-v7a/objs/monitor/Processor.o: in function hrm::Processor::Processor():jni/Processor.cpp:15: error: undefined reference to 'hrm::TestModule::TestModule()'
`collect2: ld returned 1 exit status
make: *** [obj/local/armeabi-v7a/libmonitor.so] Error 1`
Sorry for bad English.
Please help.
I found answer. See diff's
jni/Android.mk
LOCAL_PATH := $(call my-dir)
MY_ROOT := $(LOCAL_PATH)
include $(call all-subdir-makefiles)
include $(CLEAR_VARS)
LOCAL_PATH := $(MY_ROOT)
LOCAL_MODULE := monitor
LOCAL_C_INCLUDES := $(LOCAL_PATH)/test_module
LOCAL_SRC_FILES := MonitorPreview.cpp \
Processor.cpp
LOCAL_LDLIBS := -llog -landroid
include $(BUILD_SHARED_LIBRARY)
$(call import-module test_module)
jni/test_module/Android.mk
LOCAL_PATH := $(call my-dir)
$(info local path = $(LOCAL_PATH))
include $(CLEAR_VARS)
LOCAL_MODULE := test_module
LOCAL_SRC_FILES := IModule.cpp \
TestModule.cpp
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
include $(BUILD_STATIC_LIBRARY)

how to generate two .so file in a single android.mk file

I'd like to create two .so file within a single .mk file. But the following codes fails because there should not be a space in LOCAL_MODULE. So is there a way out?
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := gpio hello-jni
LOCAL_CFLAGS := -Werror
LOCAL_SRC_FILES := gpio.c hello-jni.c
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
I just got it works using the following codes.
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := gpio
LOCAL_CFLAGS := -Werror
LOCAL_SRC_FILES := gpio.c
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := h ello-jni
LOCAL_CFLAGS := -Werror
LOCAL_SRC_FILES := hello-jni.c
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)

Android NDK: Including boost c++ library

I am trying to use a boost library inside my android application, using the NDK. I have found a couple of success stories here and here, but I can't say the same about me. I am specifically trying to use the library in this link, as well as the boost thread library. In the code below, I am only trying to include the thread library, not the math library. The process I used to build the boost libraries is pretty much the same as the first link I attached.
So far, it seems I have successfully built the boost libraries, but when I run ndk-build, I get the following error:
Prebuilt : libboost_thread.a <= <NDK>/sources/
cp: omitting directory `path/to/ndk/sources/boost'
make: *** [obj/local/armeabi/libboost_thread.a] Error 1
Obviously the cp: omitting directory... is not exactly an error. But the only thing I'm getting other than that is the next line, which doesn't really mean anything. Error 1
Here's my Android.mk file:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_STATIC_LIBRARIES := boost_thread
LOCAL_LDLIBS := lboost_system-gcc-md lboost_thread-gcc-md -lgnustl_static
LOCAL_LDLIBS += lboost_system-gcc-md lboost_thread-gcc-md \
-L$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/libs/armeabi \
-lgnustl_static
LOCAL_SRC_FILES := #cpp_sources
LOCAL_MODULE := com_example_ndkFile_CppMethods
include $(BUILD_SHARED_LIBRARY)
$(call import-module,boost)
And there's also an Android.mk file in path/to/ndk/sources/boost/:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE:= boost_thread
LOCAL_SRC_FILES:= android/lib/libboost_thread.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
include $(PREBUILT_STATIC_LIBRARY)
And my humble Application.mk file:
APP_ABI := armeabi armeabi-v7a
APP_STL := gnustl_static
APP_CPPFLAGS = -fexceptions
I built the boost libraries using bjam. All of the libboost_###.a files are in the sources/boost/android/lib folder.
What is the error I'm getting?
I built the boost libraries using Boost-for-Android. Then I have in my boost/include/lib directory the android makefile boost.mk
LOCAL_PATH := $(call my-dir)
# boost_date_time
#
include $(CLEAR_VARS)
LOCAL_MODULE := boost_date_time
LOCAL_SRC_FILES := libboost_date_time-gcc-mt-1_53.a
include $(PREBUILT_STATIC_LIBRARY)
# boost_filesystem
#
include $(CLEAR_VARS)
LOCAL_MODULE := boost_filesystem
LOCAL_SRC_FILES := libboost_filesystem-gcc-mt-1_53.a
include $(PREBUILT_STATIC_LIBRARY)
# boost_thread
#
include $(CLEAR_VARS)
LOCAL_MODULE := boost_thread
LOCAL_SRC_FILES := libboost_thread-gcc-mt-1_53.a
include $(PREBUILT_STATIC_LIBRARY)
# boost_system
#
include $(CLEAR_VARS)
LOCAL_MODULE := boost_system
LOCAL_SRC_FILES := libboost_system-gcc-mt-1_53.a
include $(PREBUILT_STATIC_LIBRARY)
# boost_program_options
#
include $(CLEAR_VARS)
LOCAL_MODULE := boost_program_options
LOCAL_SRC_FILES := libboost_program_options-gcc-mt-1_53.a
include $(PREBUILT_STATIC_LIBRARY)
# boost_chrono
#
include $(CLEAR_VARS)
LOCAL_MODULE := boost_chrono
LOCAL_SRC_FILES := libboost_chrono-gcc-mt-1_53.a
include $(PREBUILT_STATIC_LIBRARY)
and my module where i use some of the boost libraries looks like this
LOCAL_PATH := $(call my-dir)
# SignalServer, executable
#
include $(CLEAR_VARS)
LOCAL_CFLAGS := -DTIXML_USE_TICPP
#LOCAL_CFLAGS += -DDEBUG
LOCAL_STATIC_LIBRARIES := boost_thread \
boost_system \
boost_filesystem \
boost_program_options \
boost_chrono \
LOCAL_STATIC_LIBRARIES += ticpp \
tia \
tobicore \
tobiid \
tid \
gdf
LOCAL_MODULE := signalserver
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_C_INCLUDES += $(LOCAL_PATH)/extern/include
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../boost/include/boost-1_53
LOCAL_SRC_FILES := #cpp source
include $(BUILD_EXECUTABLE)
in addition I have an Android.mk where all subdir makefiles are listed
TOP_PATH := $(call my-dir)
include $(TOP_PATH)/boost/lib/boost.mk
include $(TOP_PATH)/signalserver/signalserver.mk
.
.
and my Application.mk:
APP_PLATFORM := android-14
APP_ABI := armeabi-v7a
#APP_OPTIM := debug
#NDK_DEBUG := 1
NDK_TOOLCHAIN_VERSION := 4.6
APP_STL := gnustl_static
APP_CPPFLAGS := -fexceptions -frtti
Here: http://silverglint.com/boost-for-android/ you can find a simple script that lets you build a modern version of boost for android, or simply download prebuilt boost binaries.
Also included is a sample test app that shows you how to include/link the boost headers/binaries

Categories

Resources