不能包含NDK头文件

时间:2022-03-30 15:07:12

i wrote a simple C++ Programm using NDK, and it works fine. Now I want to add the following header file for using logging functions:

我用NDK编写了一个简单的C ++程序,它运行正常。现在我想添加以下头文件以使用日志记录功能:

android\log.h

My Android.mk look like this:

我的Android.mk看起来像这样:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_LDLIBS:= -llog

LOCAL_MODULE    := ndkmodulea
LOCAL_SRC_FILES := ndkmodulea.cpp

include $(BUILD_SHARED_LIBRARY)

My .cpp file starts like this:

我的.cpp文件如下所示:

#include <jni.h>            
#include <string.h>
#include <android\log.h>

if i try to run ndk-build (via terminal) inside the android project folder, I'll get following error message:

如果我尝试在android项目文件夹中运行ndk-build(通过终端),我将收到以下错误消息:

Compile++ thumb  : ndkmodulea <= ndkmodulea.cpp
jni/ndkmodulea.cpp:4:25: fatal error: android\log.h: No such file or directory
compilation terminated.
make: *** [obj/local/armeabi/objs/ndkmodulea/ndkmodulea.o] Error 1

Can somebody help or teach me how to correctly include such header files? Many thanks in advance!

有人可以帮助或教我如何正确包含这样的头文件?提前谢谢了!

1 个解决方案

#1


2  

Use forward slashes in #include paths:

在#include路径中使用正斜杠:

#include <android/log.h>

#1


2  

Use forward slashes in #include paths:

在#include路径中使用正斜杠:

#include <android/log.h>