We're a pretty Mac first development team at Hello Lightbulb. All the assets, code and game tests are done on a Mac which is fine, but not particularly ideal since mode people play games on Windows machines.
Since I'm quite new to game development I thought this wouldn't be a problem. Once we were ready to share w build with the world I'll just export a Windows version of the game in a few clicks, or in the case of HaxeFlixel/OpenFL I'll just run lime build windows
in the command line from my Mac. Little did I know how wrong that was.
In the end, we did get a Windows port of the game out but through a lot of sweat and tears, and a bunch of free online tools. Below I'm going to write down exactly how we did it.
Note: This guide is not just for those on a Mac who want to export a Windows version of their game it also applies to people on a Linux machine as well. If you're having a similar problem on a Windows machine please start from step 3.
1. Install Virtualbox
I know there are virtual build tools for Haxe like Neko and Hashlink but in my experience (only with Neko), the build ended up being slower than a native build. So if you're able to I would highly recommend getting Virtualbox and installing it for free.
Go to the Virtualbox download site and download a copy for the OS you are on, (Mac or Windows).
2. Install a Windows 10
You can get a copy of Windows 10 which Microfot provide for free mainly for testing older versions of Internet Explorer but you get the full OS.
Navigate to the virtual machines page on the Microsoft site and pick Windows 10 for Virutalbox.
I stress the importance of using Windows 10. I tried Windows 7 before and got errors I couldn't resolve.
3. Install Visual Studio Community 2019
Haxe (or to be more specific hxcpp) needs the C++ compiler from this to compile a native Windows version of your project, but it's a bit more complicated to setup than clicking next through the installation wizard.
Open up the Windows Virtualbox image and download VSC 2019 from the Visual Studio website. Once again I stress getting version 2019 and not 2017. I've seen in some OpenFl forums that 2017 has worked for some people but if you follow this guide 2019 should work for fine.
During your VSC 2019 installation, you'll see an option for workloads, don't select any of them, instead, go to the individual components tab and select the following:
This will make the instalment around 22GB so please make sure you have that much room on your machine.
After this, restart your machine before moving on to the next step.
4. Install Haxe and it's dependencies
Once you've done the previous steps correctly it should be smooth sailing from here.
You can download Haxe for Windows with the installer from the official Haxe site.
Once that's done you should have access the haxelib and be able to install the following dependances.
haxelib install lime
haxelib install openfl
haxelib install flixel
haxelib install hxcpp
There is a chance hxcpp
will tell you it's already been installed, if that's the case make sure it's up-to-date with the following command.
haxelib update hxcpp
5. Build your game 🎉
Once everything above has been completed and you have no errors, you should be able to build your project successfully with the following command.
lime build windows
Once that has worked if you would like to share your project with friends or online you'll need to share EVERYTHING in the export -> windows -> bin folder, not just the .exe file. I made that mistake before.
Anyways, I hope you've found this post useful and if you have any questions/issues feel free to ask them in the Haxe Discord server as I'm on there quite regularly. Also, I'd love it if you could play the game I'm working on https://hellolightbulb.itch.io/scales
It would mean so much to have as many people try it and give feedback, thanks.
Top comments (0)