C++17 support for Android/iOS?

C++17 support for Android/iOS?
0.0 0



Has anyone successfully used C++17 for Android and iOS?
I can’t test iOS atm, but i tried to enable it on android but it seems like it doesn’t work?
“unrecognized command line option ‘-std=c++17’”

as far as i know it should work with NDK 15


Would be awesome to have this indeed! Please tag me if you get it to work.


iOS works. Android I have never tried


i tried by just adding -std=c++17 but it didn’t work, i dont know which compiler we use with ndk r15


I’ll think we are using gnustl (see the Application.mk file in github) and that should not be able to use c++17 - Apart from that the cocos2d-x team should switch to libc++, because gnustl will be removed in the future -> https://developer.android.com/ndk/guides/cpp-support.html#gnustl

Am I right @slackmoehrle?


Seems like we can’t simply just changes it right?
I tried, but it still can’t use the c++17 flag


@mars3142 is libc++ stable now?


is there away to change it to libc++?


I don’t think so, because NDK r16 is still in beta and the latest version can’t be used yet.


@Sleicreider you can change it yourself, but because it is not stable and we met strange crash issues when changing it in 3.11 or some other version, i suggested not using libc++.


would be great to get an update, when we know that c++17 is supported or libc++ is working :slight_smile:


What update do you need?


as the others siad libc++ might not be working correctly with cocos at the moment.
if anyone gets it working without any Problem it would be great to update this thread.
Hopefully with the next ndk update, since they want to make libc++ the default anyway


there was somewhere a post about this commit “rebuild all libs for android with clang+libc++” for ndk16 support with libc++, and I tried it over night, but wasn’t to create a successfull build.


I use C++14 in my projects by just changing it in the Application.mk. If 17 doesn’t work, it probably because the ndk doesn’t support it yet. Let me do some research

Also, Try the latest git branch which changes a lot of things on the android side.


yeah i’m also using c++14 already, as the other mentioned libc++ is causing some issues, and i think the cocos Team is already starting to Switch over to libc++ as i’ve seen in the recent commits. I guess with the next cocos2d-x Version it will be supported officially.

I’ve only tried the cocos2d-x v3 branch yet, maybe you’re right and the other might work, I’ll give it a shot.

But what I’ve experienced so far is that either way, lots of files changes are required due to the gradle 3.x update, hopefully there will be a easier way than changing everything manually


This is the only branch you should be using.


oh ok, I prob. just wait for the next cocos release.


since we have 3.17 now I’ll want to check the status of this again. I’ve tried to compile android with the latest ndk libc++ and c++1z enabled and it seems to look promising, but had some issues with the SDKBox plugins (looks like IAP) causing the my project to crash with the new update, not exactly sure why at the moment.


I’ve quickly created a new 3.17 project and added all my changes / code and resources from 3.16 and it seems like c++17 works fine now on Android, even SdkBox seems to work now. There were some deprected stuff I had to remove from the engine(deprecated stuff anyway) since c++17 removed several std lib functions but beside that everything works just fine.

Haven’t tested IOS and OSX yet, but i think as far as i remember from 3.16 those worked anyway, I think only Android had some issues.