我正在为Android6编写一个C程序,这是我的Android.mk
APP_PLATFORM := android-23
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# Enable PIE manually. Will get reset on $(CLEAR_VARS). This
# is what enabling PIE translates to behind the scenes.
LOCAL_CFLAGS += -fPIE -DHAVE_FANOTIFY=1 -DHAVE_SYS_FANOTIFY=0
LOCAL_LDFLAGS += -fPIE -pie
# give module name
LOCAL_MODULE := fsmon
# list your C files to compile
LOCAL_SRC_FILES := inotify.c fanotify.c util.c main.c
# this option will build executables instead of building library for android application.
include $(BUILD_EXECUTABLE)在fanotify.c中,编写了以下内容:
#include <linux/fanotify.h>当我尝试使用ndk-build时,会出现以下错误:
fsmon/jni/fanotify.c:51:10: fatal error: 'linux/fanotify.h' file not found
#include <linux/fanotify.h>
^头fanotify.h存在于ndk路径/Android/Sdk/ndk-bundle/sysroot/usr/include/linux中。
有什么建议吗?
编辑:如果我尝试包含sys/fanotify.h,同样的错误
发布于 2017-03-30 19:49:09
可以使用LOCAL_C_INCLUDES为模块指定其他包含路径。
LOCAL_C_INCLUDES := /Android/Sdk/ndk-bundle/sysroot/usr/include/
发布于 2017-03-31 20:25:30
从历史上看,NDK不支持旧版本的头,但是我们已经在r14中重新处理了一些事情,所以这是可能的:https://android.googlesource.com/platform/ndk/+/ndk-r14-release/docs/UnifiedHeaders.md
默认情况下,在r14中,仍然会得到标头的旧形式。新的“统一标题”有您要寻找的标头。如果要尝试统一头,请在APP_UNIFIED_HEADERS := true中设置Application.mk (其他构建系统的设置可以在上面的链接中找到)。
在r15 (即将发布的第一个测试版)中,默认值已更改为新的标头,禁用它们的选项已经更改(有关选项的更改:https://android.googlesource.com/platform/ndk/+/ndk-r15-release/docs/UnifiedHeaders.md),请参见r15中的相同文档。
https://stackoverflow.com/questions/43124522
复制相似问题