title: How Android executables are built?
body: <p>I am trying to write a program for an executable which is similar to dumpsys. I have created a .cpp file and an Android.mk file. However, when I run <code>ndk-build</code> on either programs, I get compilation error. On the other hand, the same dumpsys program is built correctly when I compile the whole Android source.</p>
  
  <p>The first error I get is
  <code>fatal error: utils/Log.h: No such file or directory</code>. Then I have to use <code>LOCAL_C_INCLUDES</code> to solve this.</p>
  
  <p>Next, I get undefined reference to <em>methods</em> errors like undefined reference to android::String16::String16().</p>
  
  <p>After that, I link some objects like String16.o to solve this issue. But some of them depend on other objects and I have to add the one by one. I don't know how Android build compiles dumpsys without facing such issues.</p>
  
  <p>How is ndk-build different from compiling the whole Android source? What is the right way to build if I want to compile a standalone project?</p>