I‘m trying to build a executable that linking android system library statically in windows, I use the following command:
%NDK_PATH%\toolchains\arm-linux-androideabi-4.8\prebuilt\windows-x86_64\bin\arm-linux-androideabi-gcc.exe jni\main.c -o main --sysroot=%NDK_PATH%\platforms\android-9\arch-arm -static
Sometime maybe need to add options:
-static-libgcc -static-libstdc++ -std=gnu99
The output file is what I want after building.
But if I want to build the executable use jni\Android.mk and jni\Application.mk via ndk-build, which option:
-static -static-libgcc -static-libstdc++ -std=gnu99
should I append and which .mk file should I choose?
I try to add:
LOCAL_CFLAGS := -static
into the jni\Andorid.mk, but the output is not changed.
How to solve the .mk problem?
You can use in your Android.mk
LOCAL_LDFLAGS := -static
The result is not identical to the simple gcc one-liner, but arm-linux-androideabi-nm reports no dynamic symbols for me.