How to Compile C++14 code for Android?

时光毁灭记忆、已成空白 提交于 2020-01-12 14:30:50

问题


Is it possible to compile C++14 source code for Android with ndk10d? I've tried both g++ and clang compilers but it seems that -std=c++14 -std=c++1y flags do not work.

If I use c++_static as my APP_STL, i get the following error:

User/someone/Software/Android/android-ndk-r10d/platforms/android-17/arch-arm/usr/include/locale.h:55:1: error: empty struct has size 0 in C, size 1 in C++

Edit: I am using Mac OSX 10.10.4 with Xcode 6.3.2 (able to compile C++14 for iOS).


回答1:


I use android-ndk-r12b-windows-x86_64, compile success with -std=c++14

Android.mk

LOCAL_CPPFLAGS  = -Wall -std=c++14



回答2:


If someone needs an answer to this question, I have found it here.

It's called CrystaX and basically it is a modified version of the Android NDK that allows targeting C++14, Boost libraries and has a number of other features.




回答3:


I'm using the following directives in my Application.mk. Switching to the clang toolchain via NDK_TOOLCHAIN_VERSION solved a bunch of problems.

APP_CPPFLAGS += -std=c++14
APP_STL := c++_static
NDK_TOOLCHAIN_VERSION := clang



回答4:


If I use c++_static as my APP_STL, i get the following error:

User/someone/Software/Android/android-ndk-r10d/platforms/android-17/arch-arm/usr/include/locale.h:55:1: error: empty struct has size 0 in C, size 1 in C++

I'm getting the same when I'm using iostream. But this is only a warning (I'm using NDK 10e) and it builds just fine. The warning is "-Wextern-c-compat" which you could turn off just like any other warning.



来源:https://stackoverflow.com/questions/31403014/how-to-compile-c14-code-for-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!