我正在尝试为Android 6编译一个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
当我尝试使用ndk-build
,会出现以下错误:
fsmon/jni/fanotify.c:51:10: fatal error: 'linux/fanotify.h' file not found #include ^
标题fanotify.h
出现在ndk路径/Android/Sdk/ndk-bundle/sysroot/usr/include/linux
有什么建议?
编辑:如果我尝试包含sys/fanotify.h
相同的错误
您可以使用LOCAL_C_INCLUDES
为模块指定其他包含路径。
LOCAL_C_INCLUDES := /Android/Sdk/ndk-bundle/sysroot/usr/include/
NDK历史上没有向旧版本反向移植标题,但我们在r14中重新设计了这些内容,因此这是可能的: https : //android.googlesource.com/platform/ndk/+/ndk-r14-release/docs/UnifiedHeaders .MD
默认情况下,在r14中,您仍然可以获得旧标题的forms。 新的“统一标题”包含您正在寻找的标题。 如果要尝试统一标头,请在Application.mk中设置APP_UNIFIED_HEADERS := true
(其他构建系统的设置可以在上面的链接中找到)。
在r15(即将推出的第一个测试版)中,默认值已更改为新标题,并且禁用它们的选项已更改(有关选项更改,请参阅r15中的相同文档: https : //android.googlesource.com/platform /ndk/+/ndk-r15-release/docs/UnifiedHeaders.md )。
以上就是c/c++开发分享Android无法在Android程序中使用Android.mk包含Linux相关内容,想了解更多C/C++开发(异常处理)及C/C++游戏开发关注计算机技术网(www.ctvol.com)!)。
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/c-cdevelopment/522193.html