I’m using the new v4 and everything compiles and runs great on iOS.
However, I’m having an issue compiling in Android Studio. I’m attempting to pass -std=c++17 in build.gradle externalNativeBuild.cmake.cppFlags to the clang compiler but it is always overridden by a subsequent flag ‘-std=gnu++11’, causing it to ignore my flag.
I’m not sure if this flag is being added by the cocos build system or is something to do with cmake itself.
Here are the commands passed to clang++:
…/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=aarch64-none-linux-android21 --gcc-toolchain=…/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64 --sysroot=…/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -DANDROID -DCOCOS2D_DEBUG=1 -DLWS_WITH_LIBUV -DMyGame_EXPORTS -DUSE_FILE32API -I…/…/…/…/…/…/Classes -I…/…/…/…/…/…/cocos2d/cocos/audio/include -I…/…/…/…/…/…/cocos2d -I…/…/…/…/…/…/cocos2d/cocos -I…/…/…/…/…/…/cocos2d/extensions -I…/…/…/…/…/…/cocos2d/cocos/platform -I…/…/…/…/…/…/cocos2d/cocos/editor-support -I…/…/…/…/…/…/cocos2d/cocos/base -I…/…/…/…/…/…/cocos2d/cocos/platform/android -isystem …/…/…/…/…/…/cocos2d/external/Box2D/include -isystem …/…/…/…/…/…/cocos2d/external/chipmunk/include -isystem …/…/…/…/…/…/cocos2d/external/freetype2/include/android/freetype2 -I…/…/…/…/…/…/cocos2d/external/recast/… -isystem …/…/…/…/…/…/cocos2d/external/jpeg/include/android -isystem …/…/…/…/…/…/cocos2d/external/uv/include -isystem …/…/…/…/…/…/cocos2d/external/webp/include/android -isystem …/…/…/…/…/…/cocos2d/external/bullet/include -isystem …/…/…/…/…/…/cocos2d/external/bullet/include/bullet -isystem …/…/…/…/…/…/cocos2d/external/openssl/include/android -isystem …/…/…/…/…/…/cocos2d/external/tiff/include/android -isystem …/…/…/…/…/…/cocos2d/external/websockets/include/android -I…/…/…/…/…/…/cocos2d/external/tinyxml2/. -I…/…/…/…/…/…/cocos2d/external/xxhash/. -I…/…/…/…/…/…/cocos2d/external/xxtea/. -I…/…/…/…/…/…/cocos2d/external/clipper/. -I…/…/…/…/…/…/cocos2d/external/edtaa3func/. -I…/…/…/…/…/…/cocos2d/external/ConvertUTF/. -I…/…/…/…/…/…/cocos2d/external/poly2tri/… -I…/…/…/…/…/…/cocos2d/external/md5/… -isystem …/…/…/…/…/…/cocos2d/external/curl/include/android -isystem …/…/…/…/…/…/cocos2d/external/png/include/android -I/Users/timwebster/Library/Android/sdk/ndk-bundle/sources/android/cpufeatures -I…/…/…/…/…/…/cocos2d/external/android-specific/pvmp3dec/include -I…/…/…/…/…/…/cocos2d/external/android-specific/pvmp3dec/src -I…/…/…/…/…/…/cocos2d/external/android-specific/tremolo/. -isystem …/…/…/…/…/…/cocos2d/external/zlib/include -I…/…/…/…/…/…/cocos2d/external/unzip/. -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -Wa,–noexecstack -Wformat -Werror=format-security -std=c++17 -frtti -fexceptions -fsigned-char -O0 -fno-limit-debug-info -fPIC -std=gnu++11 -MD -MT CMakeFiles/MyGame.dir/Classes/AppDelegate.cpp.o -MF CMakeFiles/MyGame.dir/Classes/AppDelegate.cpp.o.d -o CMakeFiles/MyGame.dir/Classes/AppDelegate.cpp.o -c …/…/…/…/…/…/Classes/AppDelegate.cpp
Notice at the end my c++17 flag is there, but then so is gnu++11. And sure enough, c++17 features are not available. Does anyone know where that final gnu++11 flag is coming from and how to remove it? I’ve searched far and wide on the interwebs and so far nothing has been able to remove that flag!
Would appreciate any help.