Unable to build for Android - stddef.h not found

  • Hey, guys.

    I'm new to HaxeFlixel (and Haxe in general) and I'm trying to build my test project for a few different platforms. I've tried Windows and Android, both of which worked wonderfully in the beginning. Windows still works, but Android does not.

    There's no rhyme or reason why, but sometimes when I attempt to build my game for Android, I get an error about stddef.h not being able to be found in my Android NDK path, so the build fails. I ran the "lime setup android" command and went through all the steps. I assume it was setup correctly because I was able to build for Android with no problem at first. I got my APK, put it on my phone, and it worked. I went through the process of making some changes to my project, rebuilding, repeat. It worked two or three times, but then the next time it failed and I was given this error:

    C:\Code\HAXE\HaxeFlixel\DungeonCrawlerTutorial>lime build android
    Creating C:/Code/HAXE/HaxeFlixel/DungeonCrawlerTutorial/export/android/obj/obj/android-v7/__pch/haxe/hxcpp.h.gch...
    In file included from C:/HaxeToolkit/installs/hxcpp/3,3,49/include/hxcpp.h:20:0:
    C:\Users\Parker\AppData\Local\Android\ndk/platforms/android-9/arch-arm/usr/include/stdint.h:31:20: fatal error: stddef.h: No such file or directory
    #include <stddef.h>
    compilation terminated.
    Error: error running arm-linux-androideabi-g++ -Iinclude --sysroot=C:\Users\Parker\AppData\Local\Android\ndk/platforms/android-9/arch-arm -IC:\Users\Parker\AppData\Local\Android\ndk/sources/cxx-stl/gnu-libstdc++/4.9/include -IC:\Users\Parker\AppData\Local\Android\ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/include -DHXCPP_VISIT_ALLOCS -DHXCPP_API_LEVEL=330 -IC:/HaxeToolkit/installs/hxcpp/3,3,49/include -Iinclude -fpic -fvisibility=hidden -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums "-D_LINUX_STDDEF_H " -Wno-psabi -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=9 -Wa,--noexecstack -O2 -DNDEBUG -c -Wno-invalid-offsetof -frtti -o C:/Code/HAXE/HaxeFlixel/DungeonCrawlerTutorial/export/android/obj/obj/android-v7/__pch/haxe/hxcpp.h.gch C:/HaxeToolkit/installs/hxcpp/3,3,49/include/hxcpp.h

    But nothing was changed. I deleted my Android NDK folder and reinstalled it and it started building again, but only a few times before the same error came up.

    What could be causing this and how can I fix it? Thanks for any help!

  • Hey! I'm also new to HaxeFlixel, only tried compiling demos from flixel-demos to see if they're mobile compatible. After jumping through a few hoops I managed to get the Flixius project to work successfully on Android. From what I see your problem is a bit like mine: hxcpp (or is it NDK itself?) tries to search for a file within the library in the wrong location. The file in issue was libgcc.a, and I realized that all I needed to do was change the name of the folder where libgcc.a was (originally it was 4.9.x) to 4.9, and Haxe then successfully compiled. You could try searching inside the folder of Android NDK to find stddef.h, and copy the header file and see if it works (assuming it's inside the NDK somewhere else). Other than that, I dunno.

  • Hey, thanks for the response! I actually came across that issue myself where I had to change the directory name, but this problem is separate from that one. It worked a few times after I changed the directory name, but then I started running into this issue.

    I found a version of stddef.h in the linux folder, so I tried copying that over just to see if it it helps, and then I got errors about stdarg.h missing. So I seems to be missing a few files and I have no idea why. I redownloaded Android NDK and these files aren't included in a fresh download either.

    So I'm at a complete loss and have no idea what the issue is. I guess this isn't a common issue because no one else seems to quite know what it is either.

  • Maybe it's the SDK Tools and APIs? I have these installed:
    SDK Build Tools 19.1
    SDK Buils Tools 23.0.3
    SDK Tools 25.1.7
    Android 4.1.2 (API 16)
    Android 4.4.2 (API 19)
    Android 6.0 (API 23)

    If I remember, Build Tools 19.1 and Android 4.4.2 (API 19) are needed and the latest SDK Tools.

    You can set the paths manually without running openfl setup android in .hxcpp_config.xml. I'm on Windows, so it's in my Users/Dean/ folder. Not sure abour Linux.

    Hope it helps. If not, you might try the OpenFL forums.

  • @dean poker158149 is on Windows you can tell by "C:\Users\Parker"
    If he was on Linux it would be something like "/home/parker"

    This looks like the root of your issue:
    Creating C:/Code/HAXE/HaxeFlixel/DungeonCrawlerTutorial/export/android/obj/obj/android-v7/__pch/haxe/hxcpp.h.gch...
    In file included from C:/HaxeToolkit/installs/hxcpp/3,3,49/include/hxcpp.h:20:0:

    Try running:
    lime clean android

    The other thing it might be is that you need to reinstall hxcpp

  • @dean
    Thanks for the info, I do have all of the appropriate SDK's and such installed and working. I've used them before without issue, but I am new to using the NDK, which is where the problem seems to exist.

    I ran the clean commands and reinstalled hxcpp to make sure it was fresh, and no luck. It seems like it may be something related to the Android NDK. I'm new to using that and simply unzipped it and then pointed lime to it. Is there anything else I need to do in relation to Android NDK other than unzip it? Thanks for your help so far!


    I seemed to have figured out a potential fix for the issue and will share it for those who are interested.
    The version of Android NDK that I was using that kept giving me the issue was revision 12b.
    I decided to revert to an older version to see if it would help, so I reverted to revision 11c and it fixed the issues!
    I'm not sure if something's wrong with version 12 of Android NDK, but reverting back to version 11 seems to have solved my problems.

  • Interesting. I guess perhaps the NDK r12b is way too 'new' where the devs for HaxeFlixel/OpenFL/Lime have not been able to fully check it and integrate all the necessary stuff. Considering that OpenFL still recommends r8b and does not officially support newer versions as shown in their page, you're OK. Already there's still the problem that HaxeFlixel 4.x series are not yet compatible with OpenFl 4.x and Lime 3.x series as well. We'll have to wait I guess.

    Although I'm intrigued at this since it didn't happen to me; the folder name change sufficed and I was able to compile the Flixius project successfully. I installed the Android Studio bundle (2.1.2) with the SDKs included for this. Did you do the same or it's just the SDKs that you have listed above?

  • I kept thinking about the fact that HaxeFlixel uses older versions of OpenFL and Lime, and thought maybe it was those that wanted the older versions of the NDK. I did not install the Android Studio bundle, I only grabbed the raw SDKs.

    It is really interesting that it worked for you but not for me. Maybe the Android Studio bundle fixes whatever the issue is that I'm having with the raw SKD.

  • Poker158149, for some reason, when I ran the Multitouch project on Flixel-Demos I was unable to compile and had the exact same error as you had. Since then I'm unable to compile any other project, despite me setting android to minimum-sdk-version at 18 and target-sdk-version at 23. I recall changing something else within the project file of Flixius, but I can't remember, and now I can't recompile it! Now I realize the fact that hxcpp forces to compile to android-9 by default when in fact it should compile to android-18 or android-23, because this error is encountered since android-9 is so old. I've been trying to find the code for this, but so far I've failed since I'm unable to find the exact file that forces android-9 to be used for compilation.

Log in to reply

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.