Search code examples
androidandroid-ndktoolchain

native_app_glue with a standalone toolchain and makefile


I have a standalone toolchain created following these instructions: https://wiki.libsdl.org/Android#Install_SDL_in_a_GCC_toolchain

My project uses an API that needs an ANativeWindow and therefore contains the line:

  #include <android_native_app_glue.h>

There is no directory "sources/native_app_glue", and no native_app_glue.o (nor .a), in the generated standalone toolchain.

How can I link native_app_glue to my application in a makefile? (without android studio, gradle, clang)

Should I compile the contents of NDK's "sources/native_app_glue", link it to my application, using the standalone toolchain? And how?


Solution

  • Yes, adding sources/native_app_glue/android_native_app_glue.c to the list of files you compile, should be enough. No special settings are required. You may find that you must add some NDK shared libs to your link command.