Printing Cross Compiled libraries(C/C++) Log (printf) in Android (Logcat)

1,598 views
Skip to first unread message

Rao Saifullah

unread,
Aug 25, 2015, 3:53:13 AM8/25/15
to android-ndk
I cross compiled some C/C++ static libraries using Netbeans for android (arm-linux-androideabi). Those libraries have log information, which i want to see while the application run on the phone (adb mode). is there any way, that those log information present in C/C++ cross compiled static libs can be displayed on logcat or anywhere else in Android studio. The log information in static libraries are just information printing using printf.

Andrew Esh

unread,
Aug 26, 2015, 5:22:54 PM8/26/15
to android-ndk

Enable stdio Redirection
Edit section

  1. adb remount
  2. adb shell
  3. cd system
  4. vi build.prop
  5. Add "log.redirect-stdio=true" as a new line at the bottom of the file.
  6. exit
  7. adb reboot
  8. Now stdout and stderr will be logged to logcat.
You might not have vi if you haven't installed BusyBox in your device. In that case use adb pull and adb push to update the build.prop file.

Rao Saifullah

unread,
Aug 26, 2015, 9:13:34 PM8/26/15
to android-ndk
Dear Andrew, thanks for the answer. i already read about this method but isn't this method is specifically for the System.out and System.err. As per android website. 

By default, the Android system sends stdout and stderr (System.out and System.err) output to /dev/null

Can i use the same for printf or cout also from the static cross compiled native libraries.\? 

Martin Sternevald

unread,
Aug 27, 2015, 5:38:07 PM8/27/15
to andro...@googlegroups.com
You could try redirecting printf output to your own function using <linker> -wrap

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
Visit this group at http://groups.google.com/group/android-ndk.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages