Compilation/Debug Cheatsheet for Cygwin (put the NDK and SDK in your Cygwin home dir)
Note for all: Additional include dirs, and libs may be required for compilation depending on the functionality you want to add
for x86:
client> g++.exe -fno-stack-protector -ggdb -static file.c -o file.exe
client> gcc.exe -fno-stack-protector -ggdb -static file.c -o file.exe
for x64:
client> x86_64-w64-mingw32-g++.exe -fno-stack-protector -ggdb -static file.cpp -o file64.exe
client> x86_64-w64-mingw32-gcc.exe -fno-stack-protector -ggdb -static file.cpp -o file64.exe
for Android (ARM):
client> <NDK_PATH>/build/tools/make-standalone-toolchain.sh –platform=<name> –ndk-dir=<path> –install-dir=<path>
client> <CREATED_TOOLCHAIN_PATH>/bin/arm-linux-androideabi-gcc -fno-stack-protector -ggdb -static file.c -o file
client> <CREATED_TOOLCAIN_PATH>/bin/arm-linux-androideabi-g++ -fno-stack-protector -ggdb -static file.cpp -o file
client> adb push file /data/data <-really anywhere writeable, but this is handiest since no remount is required
Note: platform name can be android-9, android-14, or any other release
GDBServer setup and adb (emulator):
client> adb -e shell
droid>gdbserver :1234 /path/to/android/binary args_to_binary
GDB client setup and adb (Windows):
client> adb pull /path/to/android/binary ./binary <-if the binary is on the device
client> adb pull /system/lib/libc.so libc.so
client> adb forward tcp:1234 tcp:1234
client> (gdb) set auto-solib-add on
client> (gdb) set solib-search-path <NDK_PATH>/platforms/<android-N>/arch-arm/usr/lib
client> (gdb) directory <NDK_PATH>/platforms/<android-N>/arch-arm/usr/include;
<NDK_PATH>/sources/cxx-stl/system <-where “N” is the platform version
client> (gdb) binary <- where binary is the name of the executable you pulled off or compiled that you want to examine
client> (gdb) target remote :1234