C++17 support for Android/iOS?

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

#1

Hey,

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


#2

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


#3

iOS works. Android I have never tried


#4

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


#5

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?


#6

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


#7

@mars3142 is libc++ stable now?


#8

is there away to change it to libc++?


#9

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


#10

@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++.


#11

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


#12

What update do you need?


#13

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


#14

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.


#15

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.


#16

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


#17

This is the only branch you should be using.


#18

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


#19

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.


#20

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.