4

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:

android\log.h

My Android.mk look like this:

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:

#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:

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!

Tho Hooves
  • 65
  • 1
  • 3

1 Answers1

3

Use forward slashes in #include paths:

#include <android/log.h>
krsteeve
  • 1,794
  • 4
  • 19
  • 29
  • That's it! Thank you very much!!! :) I almost got crazy editing the Android.mk file! - Windows user have to use backslashes #include - Linux user have to use slashes #include – Tho Hooves Oct 04 '13 at 18:51
  • Forward slashes *should* work on all platforms - and its safer just to use them if you can. – krsteeve Oct 04 '13 at 18:54
  • just to confirm they work on every platform i've ever touched - pretty much every ppc, arm, x86/x64 and mips that has been in a phone, pc or game console - and using most compilers you would care about gcc, snc, dmc, ghc, cl (msvc), clang, intel and code warrior... – jheriko Nov 27 '13 at 03:57