

Ask HN: Tools for Android NDK development? - compilercreator

Looking at porting a desktop C++ and OpenGL app to Android. Wondering what tools do you use for debugging and profiling apps on Android? Am interested in profiling both CPU code, as well as OpenGL shaders.
======
ttuominen
For CPU profiling, the Android Open Source Project includes both oprofile and
Linux perf tools in the source tree. You would need to compile your own kernel
and Android to include them. Some options need to be set in the kernel config
to enable support for processor hardware events for profiling. Additionally,
you need to compile the profiled code in ARM mode instead of Thumb for perf
tools to be able to unwind the stack traces. Oprofile might work without
kernel hardware support, I'm not sure.

I don't know about shader profiling. GDB is apparently supported for
debugging, haven't used it: <http://www.kandroid.org/online-
pdk/guide/debugging_gdb.html>

EDIT: By the way, depending on the accuracy you require, you might want to
take a look at this poor man's profiler that Mike Dunlavey has been
advocating: [http://stackoverflow.com/questions/375913/what-can-i-use-
to-...](http://stackoverflow.com/questions/375913/what-can-i-use-to-profile-c-
code-in-linux/378024#378024) It doesn't require compiling the operating
system, you can just send a kill signal to your process multiple times and
examine the stack traces from the logs. It may or may not be enough for your
needs.

------
Ologn
Be aware that Android (and I believe iOS) does not use OpenGL. It uses a
subset of OpenGL called OpenGL ES. OpenGL ES does not handle OpenGL begin and
end commands. You can not directly specify rectangles on OpenGL ES like you
can on OpenGL. There are other differences as well. So you will somehow have
to translate your OpenGL code into OpenGL ES.

I would look into this before worrying about debugging and profiling. If it
were possible to easily port OpenGL C++ apps to Android, I (and others) would
have ported every popular open source OpenGL C++ game to Android a long time
ago.

Garen Torikian and Sergii Pylypenko both have attempted to port C++/OpenGL
games to Android. There results are here and might help you:

[http://github.com/pelya/commandergenius/tree/sdl_android/pro...](http://github.com/pelya/commandergenius/tree/sdl_android/project/jni/application/openarena)

<http://gjtorikian.github.com/Neverball-ME/>

I am almost always on Freenode IRC channel #android-dev as Ologn, feel free to
send me a message as I'm interested in this topic. You also might luck out and
run into someone with some NDK/JNI experience on the IRC channel, depending on
the time of day etc.

