Android: cmake doesn't include proper header directories for arm7/api19 android ndk r20 builds
building google grpc 1.16.1 for atmeabi-v7a / android-19 using cmake 3.16.1 and android ndk r20b:
In file included from SOURCE/grpc/src/core/lib/gprpp/fork.cc:31:
In file included from SOURCE/grpc/src/core/lib/gprpp/memory.h:27:
In file included from /opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/memory:654:
In file included from /opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/typeinfo:61:
In file included from /opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/exception:82:
/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/cstdlib:155:9: error: no member named 'at_quick_exit' in the global namespace
using ::at_quick_exit;
~~^
/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/cstdlib:156:9: error: no member named 'quick_exit' in the global namespace
using ::quick_exit;
~~^
These functions exist in main (sysroot) cstdlib / stdlib.h only starting from API 21 (ifdef API >= 21).
usr/include/c++/v1/cstdlib:
#if !defined(_LIBCPP_CXX03_LANG) && defined(_LIBCPP_HAS_QUICK_EXIT)
using ::at_quick_exit;
using ::quick_exit;
#endif
usr/include/stdlib.h:
#if __ANDROID_API__ >= 21
int at_quick_exit(void (*__fn)(void)) __INTRODUCED_IN(21);
void quick_exit(int __status) __noreturn __INTRODUCED_IN(21);
#endif /* __ANDROID_API__ >= 21 */
But there are additional "android support" headers that declare them:
usr/local/include/stdlib.h (ad its former location is source/android-support/include/)
#if __ANDROID_API__ < __ANDROID_API_L__
long double strtold_l(const char*, char**, locale_t);
long long strtoll_l(const char*, char**, int, locale_t);
unsigned long long strtoull_l(const char*, char**, int, locale_t);
int mbtowc(wchar_t*, const char*, size_t);
int at_quick_exit(void (*)(void));
void quick_exit(int) __noreturn;
#endif
Looks like android command line for old architectures (arm7/api19) doesn't include these extra support headers (or includes them in incorrect order).
Not sure if this is cmake script problem or android ndk toolchain itself ...
P.S. Builds for cmake 3.15 and older and for android ndk r18 and older ...
Edited by Brad King