C/C++ printfs - 它出现在 Android 本机代码中的什么位置? [英] C/C++ printfs - Where's it appears in a Android native code?
本文介绍了C/C++ printfs - 它出现在 Android 本机代码中的什么位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
由于调试原生 android 代码非常困难,我将采用printf trace"方法.
Since It's pretty hard to debug native android code, I'm going to the "printf trace" approach.
所以,我的问题是,在原生代码中,运行 Android 应用程序时标准printf("something")"在哪里出现?
So, my question is, in a native code, wheres the standards "printf("something")" appears when running a Android application?
推荐答案
登录到logcat.
1) 要在本机代码中调用记录器,请包含标头并调用 _android_log_write(..).
1) To invoke the logger in native code include the header and call _android_log_write(..).
#include <android/log.h>
__android_log_write(ANDROID_LOG_INFO, "tag here", "message here");
2) 在您的 Android.mk 文件中包含这样的日志库.
2) In your Android.mk file include the log lib like this.
LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog
这篇关于C/C++ printfs - 它出现在 Android 本机代码中的什么位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文