为什么在 android 上重定向 stdout/stderr 不起作用? [英] Why is redirecting stdout/stderr on android not working?

查看:18
本文介绍了为什么在 android 上重定向 stdout/stderr 不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下载了 SDL 1.3 并在我的 android 2.2 设备上将它与 OpenGL ES 一起测试.它工作正常,但我没有从 printf 调用中获得输出.我尝试了 android 开发者页面 但 Eclipse 中的 DDMSadb logcat 都不会报告程序使用 printf 写入的字符串.我确保过滤 stdout 标记.

I downloaded SDL 1.3 and tested it together with OpenGL ES on my android 2.2 device. It works fine but I don't get the outputs from the printf calls. I tried the commands below as mentioned at the android developer page but neither DDMS in Eclipse nor adb logcat reports the strings that the program writes using printf. I made sure to filter for the stdout tag.

$ adb shell stop
$ adb shell setprop log.redirect-stdio true
$ adb shell start

我错过了什么或做错了什么?

What am I missing or doing wrong?

推荐答案

另一种方法是创建一个文件 /data/local.prop,其中仅包含行 log.redirect-stdio=true.也许这效果更好?另外,请注意 stdout 已缓冲,因此您的输出可能仍位于缓冲区中,等待刷新.您可以手动调用 fflush 进行检查.

Another way of doing this is having a file /data/local.prop, containing just the line log.redirect-stdio=true. Maybe this works better? Also, note that stdout is buffered, so it could be that your output is still sitting in the buffer, waiting to be flushed. You can call fflush manually to check this.

这篇关于为什么在 android 上重定向 stdout/stderr 不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆