Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Compile C++14 code for Android?

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).

like image 929
Crossfire Avatar asked Jul 14 '15 09:07

Crossfire


People also ask

Can Android run C++?

The Android Native Development Kit (NDK): a toolset that allows you to use C and C++ code with Android, and provides platform libraries that allow you to manage native activities and access physical device components, such as sensors and touch input.

What C++ compiler does Android use?

libc++ LLVM's libc++ is the C++ standard library that has been used by the Android OS since Lollipop, and as of NDK r18 is the only STL available in the NDK.

How do I open a .C file on Android?

To open a C file using a programming editor, you need to download a C programming editor on your android mobile. These programming editors are available on the google play store for free. Some of the C programming editors available on the google play store are Coding C, Cxxdroid, and C/C++ Programming Compiler.

Does Android use GCC?

Code written in C/C++ can be compiled to ARM, or x86 native code (or their 64-bit variants) using the Android Native Development Kit (NDK). The NDK uses the Clang compiler to compile C/C++. GCC was included until NDK r17, but removed in r18 in 2018.


2 Answers

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

Android.mk

LOCAL_CPPFLAGS  = -Wall -std=c++14
like image 121
KunMing Xie Avatar answered Oct 24 '22 02:10

KunMing Xie


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.

like image 30
Crossfire Avatar answered Oct 24 '22 02:10

Crossfire