Reputation: 21
I am trying to buikd a Android native module inside the Android build system using NDK. My module builds properly with out any error while building with Android module make command. But when I try the use NDK build setup I am facing problem with android system include files. My module structure is :
android
|
external
|
MyModule
|
jni --> Android.mk
mysharedobj --> Android.mk
My Native module includes many android includes such as
#include <JNIHelp.h>
#include "android_runtime/AndroidRuntime.h"
#include <gui/Surface.h>
#include <gui/ISurface.h>
With the help of NDK docs i was able to resolve the include errors, but i am facing somre error, eg:
jni/com_my_module_NativeInterface.cpp:3:21: fatal error: JNIHelp.h: No such file or directory compilation terminated.
-->For resolving the JNIHelp.h include error, i had added the following line in Android.mk
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/../../../libnativehelper/include/nativehelper
After this again one more error,
jni/../../../libnativehelper/include/nativehelper/JNIHelp.h:27:24: fatal error: cutils/log.h: No such file or directory compilation terminated.
--> To solve above error i had modified Android.mk
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/../../../libnativehelper/include/nativehelper \
$(LOCAL_PATH)/../../../system/core/include \
After this again one more error
/home/user/android-ndk-r8e/platforms/android-3/arch-arm/usr/include/linux/uio.h:18:8: error: redefinition of 'struct iovec'
jni/../../../system/core/include/cutils/uio.h:33:8: error: previous definition of 'struct iovec'
How to build a native module successfully that uses android system include files? Please help me.
Upvotes: 2
Views: 8145
Reputation: 13548
I'm not sure, but try to put the flag -DHAVE_SYS_UIO_H on your LOCAL_CFLAGS:
LOCAL_CFLAGS += -DHAVE_SYS_UIO_H
Upvotes: 5
Reputation: 5436
You should use LOCAL_LDLIBS
instead of adding ndk dependencies to LOCAL_C_INCLUDES
. The example below is from my Android.mk:
LOCAL_LDLIBS := -L$(NDK_PLATFORMS_ROOT)/$(TARGET_PLATFORM)/arch-arm/usr/lib -L$(LOCAL_PATH) -llog -lz -lm
Checkout docs to see which libs you should add for your needs.
Upvotes: 0