Is quot;std::coutquot; usable in Android-ndk(是“std::cout;可用于 Android-ndk)
问题描述
在 Android-ndk 中,我们可以使用__android_log_write"、__android_log_print"等来将消息输出到LogCat"窗口.如果我使用std::cout"输出一些字符串怎么样?例如
In Android-ndk, we could use "__android_log_write", "__android_log_print", ... etc to output messages to the "LogCat" window. How about if I use "std::cout" to output some strings ? E.g.
std::cout << "some strings" << std::endl;
字符串将被发送到哪里.
Where would the strings be sent.
Android好像没有Console Applications,上面的字符串可能发不出去.我可以将stdout"重定向到一个文件,以便将字符串发送到std::cout"相当于记录消息吗?
It seems that Android does not have Console Applications and the above strings may not be sent. Could I redirect the "stdout" to a file so that sending strings to "std::cout" is equivalent to logging messages ?
推荐答案
根据Android文档,stdout &stderr 输出到 /dev/null
.您可以使用 Android 调试桥实现你想要的.
According to the Android documentation, stdout & stderr output to /dev/null
. You can use the Android Debug Bridge to achieve what you want.
默认情况下,Android 系统将 stdout 和 stderr(System.out 和 System.err)输出发送到/dev/null.在运行 Dalvik VM 的进程中,您可以让系统将输出的副本写入日志文件.在这种情况下,系统使用日志标签 stdout 和 stderr 将消息写入日志,两者的优先级均为 I.要以这种方式路由输出,请停止正在运行的模拟器/设备实例,然后使用 shell 命令 setprop 启用输出重定向.以下是你的做法:
By default, the Android system sends stdout and stderr (System.out and System.err) output to /dev/null. In processes that run the Dalvik VM, you can have the system write a copy of the output to the log file. In this case, the system writes the messages to the log using the log tags stdout and stderr, both with priority I. To route the output in this way, you stop a running emulator/device instance and then use the shell command setprop to enable the redirection of output. Here's how you do it:
$ adb shell stop
$ adb shell setprop log.redirect-stdio true
$ adb shell start
系统会保留此设置,直到您终止模拟器/设备实例.要将设置用作模拟器/设备实例的默认设置,您可以在设备上的/data/local.prop 中添加一个条目.
The system retains this setting until you terminate the emulator/device instance. To use the setting as a default on the emulator/device instance, you can add an entry to /data/local.prop on the device.
这篇关于是“std::cout";可用于 Android-ndk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:是“std::cout";可用于 Android-ndk


基础教程推荐
- 常量变量在标题中不起作用 2021-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 这个宏可以转换成函数吗? 2022-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 如何在 C++ 中初始化静态常量成员? 2022-01-01