的Android NDK本地库,该怎么办现有的标准输入输出? [英] Android NDK Native LIB, What to do about existing stdio?
问题描述
我现有的本地C / C ++ code,我目前正在建设成通过NDK本地lib和Android应用程序。本机code是充斥着打印语句输出和错误。有没有这样的事情最好的做法?我可以不理会他们还是需要去通过,并将其重定向到Android日志系统?
I have existing native C/C++ code that I am currently building into a native lib and Android app via the NDK. The native code is riddled with print statements to stdout and stderr. Is there a best practice for something like this? Can I just ignore them or do I need to go through and redirect them to the Android logging system?
我建了现有的code作为一个独立的本机二进制,并通过亚行运行它,我所看到的的printf(到标准输出)的所有输出到控制台。
I built the existing code as a standalone native binary and ran it via adb and I was seeing all the output from printf (to stdout) to the console.
似乎是一个愚蠢的问题要问,但是在哪里呢STDIO去一个Android应用程序?
Seems like a goofy question to ask but where does stdio go for an Android app?
推荐答案
在默认情况下输出和错误被发送到/ dev / null的(无门)for Android应用程序。
By default stdout and stderr are sent to /dev/null (nowhere) for android apps.
您可以使用adb setprop设置log.redirect,标准输入输出为真,或者把log.redirect,标准输入输出=真的/data/local.prop(你可能需要root访问权限以创建,但它更可靠)。这样做将其输出发送到logcat的日志。
You can use adb setprop to set log.redirect-stdio to true, or put "log.redirect-stdio=true" in /data/local.prop (which you may need root access to create, but it's more reliable). Doing this will send their output to the logcat log.
请参阅查看输出和错误: http://developer.android。 COM /引导/开发/工具/ adb.html
See "Viewing stdout and stderr": http://developer.android.com/guide/developing/tools/adb.html
这篇关于的Android NDK本地库,该怎么办现有的标准输入输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!