Android无法在Android.mk的C程序中包含linux [英] Android can't include linux in C program with Android.mk

查看:185
本文介绍了Android无法在Android.mk的C程序中包含linux的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为Android 6编译C程序。这是我的 Android.mk

I'm trying to compile a C program for Android 6. This is my 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 ,出现以下错误:

When I try to use ndk-build, following error appears:

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

Same error if I try to include sys/fanotify.h

推荐答案

您可以使用 LOCAL_C_INCLUDES 为模块指定其他包含路径。

You can specify additional include paths for your module using LOCAL_C_INCLUDES.

LOCAL_C_INCLUDES:= / Android / Sdk / ndk-bundle / sysroot / usr / include /

https://developer.android.com/ndk/guides/android_mk .html#mdv

这篇关于Android无法在Android.mk的C程序中包含linux的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆