The method of output log information in the NDK and source code!
Ndk:
1. Include header file
#include <android/log.h>
2. ANDROID.MK contains the library
Local_ldlibs + =-l$ (sysroot)/usr/lib-llog
Above this must, otherwise appear error:undefined reference to ' __android_log_print '
Local_shared_libraries: = libdl\
Liblog\ #经测试在Eclipse中用NDK编译可有可无, no use! But in the source code must be him, so add it!
Libpre_appupgrade\
Libpre_apparea\
3. defined in your JNI file
#define LOGD (...) __android_log_print (android_log_debug,log_tag,__va_args__)//define LOGD type
#define Logi (...) __android_log_print (android_log_info,log_tag,__va_args__)//define Logi type
#define LOGW (...) __android_log_print (android_log_warn,log_tag,__va_args__)//define LOGW type
#define LOGE (...) __android_log_print (android_log_error,log_tag,__va_args__)//define Loge Type
#define LOGF (...) __android_log_print (android_log_fatal,log_tag,__va_args__)//define LOGF type
adnroid4.2 source has been added to the logd and so on a head,
#define ALOGD (...) __android_log_print (android_log_debug,log_tag,__va_args__)//define LOGD type
#define ALOGI (...) __android_log_print (android_log_info,log_tag,__va_args__)//define Logi type
#define ALOGW (...) __android_log_print (android_log_warn,log_tag,__va_args__)//define LOGW type
#define ALOGE (...) __android_log_print (android_log_error,log_tag,__va_args__)//define Loge Type
#define ALOGF (...) __android_log_print (android_log_fatal,log_tag,__va_args__)//define LOGF type
Note that if you do not want to define the above macros in each JNI file, the speculative method can be defined in: D:\android-ndk-r9d\platforms\android-19\arch-arm\usr\include\android\log.h! Of course, this compilation can only be used on your own machine ~
Source Code Development:
1. ANDROID.MK contains the library
Local_ldlibs + =-l$ (sysroot)/usr/lib-llog
Local_shared_libraries: = libdl\
liblog\//source code in the development of certain plus
Libpre_appupgrade\
Libpre_apparea\
2. Include header file # include <utils/Log.h>
3. Remember to include the header file of the library when you use it