openfl / lime

A foundational Haxe framework for cross-platform development
https://lime.openfl.org/
MIT License
749 stars 362 forks source link

Cannot compile for Android #1736

Closed RuiCuco closed 1 month ago

RuiCuco commented 7 months ago

I do on a new project:

lime build android

and after a while I receive these errors:

Compiling group: pcre2-8 arm-linux-androideabi-g++ -DPCRE2_CODE_UNIT_WIDTH=8 -DSUPPORT_PCRE2_8 -DHAVE_CONFIG_H -DPCRE2_STATIC -DSUPPORT_UNICODE -ID:/Developer/HaxeToolkit/haxe/lib/hxcpp/4,3,2/project/thirdparty/pcre2-10.42/src --sysroot=D:\Developer\Android\android-ndk-r15c/platforms/android-21/arch-arm -ID:\Developer\Android\android-ndk-r15c/sources/cxx-stl/gnu-libstdc++/4.9/include -ID:\Developer\Android\android-ndk-r15c/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/include -DHXCPP_ARMV7 -DHXCPP_VISIT_ALLOCS(haxe) -DHX_SMART_STRINGS(haxe) -DHXCPP_API_LEVEL=430(haxe) -ID:/Developer/HaxeToolkit/haxe/lib/hxcpp/4,3,2/include -Iinclude -fpic -fvisibility=hidden -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -Wno-overflow -D_LINUX_STDDEF_H -Wno-psabi -DHXCPP_CPP11 -DHXCPP_ARMV7 -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -fomit-frame-pointer -fexceptions -fno-strict-aliasing -finline-limit=10000 -DANDROID=ANDROID -DHX_ANDROID -DHXCPP_ANDROID_PLATFORM=21 -Wa,--noexecstack -O2 -DNDEBUG -c ... tags=[haxe,static]

What should I do to compile correctly for Android and thereby generate an APK?

joshtynjala commented 7 months ago

This is an hxcpp bug. It’s been fixed, but not released to Haxelib yet.

https://github.com/HaxeFoundation/hxcpp/issues/1041

You can either install hxcpp from GitHub, or you can roll back to Haxe 4.2 and hxcpp 4.2.

joshtynjala commented 1 month ago

Posting a similar error related to hxcpp and Android for anyone who might get here from Google:

Error: C:/HaxeToolkit/haxe/lib/hxcpp/git/project/thirdparty/mbedtls-2.28.2/library/constant_time.c: In function 'mbedtls_ct_memcpy_if_eq': C:/HaxeToolkit/haxe/lib/hxcpp/git/project/thirdparty/mbedtls-2.28.2/library/constant_time.c:419:5: error: 'for' loop initial declarations are only allowed in C99 or C11 mode for( size_t i = 0; i < len; i++ ) ^ C:/HaxeToolkit/haxe/lib/hxcpp/git/project/thirdparty/mbedtls-2.28.2/library/constant_time.c:419:5: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code

  • C:/HaxeToolkit/haxe/lib/hxcpp/git/project/thirdparty/mbedtls-2.28.2/library/rsa_internal.c

This seems to be related to how hxcpp compiles its mbedtls dependency. It is fixed in the following hxcpp PR (which is not merged yet, at the time I am writing this).

HaxeFoundation/hxcpp#1111