我正在尝试使用 NDK 在 Android 构建系统中构建一个 Android 本机模块。使用 Android 模块 make 命令构建时,我的模块可以正确构建,没有任何错误。但是当我尝试使用 NDK 构建设置时,我遇到了 android 系统包含文件的问题。我的模块结构是:
android
|
external
|
MyModule
|
jni --> Android.mk
mysharedobj --> Android.mk
我的本机模块包括许多 android 包括,例如
#include <JNIHelp.h>
#include "android_runtime/AndroidRuntime.h"
#include <gui/Surface.h>
#include <gui/ISurface.h>
在 NDK 文档的帮助下,我能够解决包含错误,但我面临严重错误,例如:
jni/com_my_module_NativeInterface.cpp:3:21: fatal error: JNIHelp.h: No such file or directory compilation terminated.
-->为了解决 JNIHelp.h 包含错误,我在 Android.mk 中添加了以下行
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/../../../libnativehelper/include/nativehelper
在这之后又出现了一个错误,
jni/../../../libnativehelper/include/nativehelper/JNIHelp.h:27:24: fatal error: cutils/log.h: No such file or directory compilation terminated.
--> 为了解决上述错误,我修改了 Android.mk
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/../../../libnativehelper/include/nativehelper \
$(LOCAL_PATH)/../../../system/core/include \
在这之后又出现了一个错误
/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'
如何成功构建使用android系统包含文件的本机模块?请帮我。