androidlinkerandroid-ndkwchar-tlinker-warning

Getting rid of wchar_t size linker warning


I compile my Android NDK library with -fshort-wchar. I know the RTL assumes 4-byte wchar_t, I know what I'm doing, the library works. However, on every build linker gives me the following warning for every object file:

ld.exe: warning: MyFile.o uses 2-byte wchar_t yet the output is to use 4-byte wchar_t; use of wchar_t values across objects may fail

When I provide

LOCAL_LDLIBS := --no-wchar-size-warning

This gives me an "unrecognized option" error.


Solution

  • Adding APP_LDFLAGS += -Wl,--no-wchar-size-warning (to Application.mk) works fine for me on NDKs at least as early as r7.

    I assume it would work just the same as:

    LOCAL_LDLIBS := -Wl,--no-wchar-size-warning