Android NDK Native LIB what to do with existing stdio?

I have my own C / C ++ code, which I am currently creating as a native lib and Android application through the NDK. Native code is imbued with print operations in stdout and stderr. Is there any best practice for something like this? Can I just ignore them or do I need to go through and redirect them to the Android registration system?

I built the existing code as a standalone native binary and ran it through adb, and I saw all the printf (to stdout) output to the console.

It seems like you need to ask a question, but where does stdio go to the Android app?

+2
android android-ndk native-code
Oct 10 2018-11-11T00:
source share
1 answer

By default, stdout and stderr are sent to / dev / null (nowhere) for Android apps.

You can use adb setprop to set log.redirect-stdio to true or put "log.redirect-stdio = true" in /data/local.prop (for which you may need root access to create, but it is more reliable). Doing this will send their output to the logcat log.

See "Viewing stdout and stderr": http://developer.android.com/guide/developing/tools/adb.html

+1
11 Oct 2018-11-11T00:
source share



All Articles