openfl / lime

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

Compiling for Different OSes #1738

Closed ahmutkadim closed 6 months ago

ahmutkadim commented 6 months ago

I know it is stated in readme that it is intended to be compiled for the same OS but it is not intuitive. Is there an alternative method that I can use to distribute apps in different Desktop OSes from the same OS. I use MacOS.

joshtynjala commented 6 months ago

The only option to compile for other operating systems from macOS would be to run virtual machines with those other operating systems. So you’d be compiling in the other OS, but you’d need only the one computer.

A requirement to compile for a specific OS from the same OS is very common for cross platform toolkits. So it’s not a unique limitation of Lime/OpenFL.

ahmutkadim commented 6 months ago

I do not have enough hardware resources to allocate to a virtual machine. And I think it kinda is since many game creation tools provide support to build for different operating systems via export templates. Is there a similar alternative?

joshtynjala commented 6 months ago

If you want to build a Windows app, you must do it on Windows. If you want to build a macOS app, you must do it on macOS. If you want to build a Linux app, you must do it in Linux. Android and iOS are special cases that can be build from another operating system (Android from Windows/macOS/Linux, but iOS from macOS only), but that's basically the only option for targeting a different operating system.

I'm sorry, but the README is correct. You either need VMs or multiple computers.

player-03 commented 6 months ago

I mean, people have attempted to add cross-compilation support to Lime (see #1661), and GCC can be configured to do it, so it isn't like it's impossible. Just maybe not something that we've successfully done here with Lime.

For an easier alternative, it ought to be possible to compile for HL, and then use premade wrappers or scripts to run that bytecode on whatever machine you like. See #1610 for more on that.

DigiEggz commented 6 months ago

Using changes made by @tobil4sk, I've been able to compile a native c++ Windows app from macOS. A few PRs were recently merged within hxcpp to make this possible (https://github.com/HaxeFoundation/hxcpp/pull/1045 and https://github.com/HaxeFoundation/hxcpp/pull/1046) and now I think the only one left to approve is #1661.

ahmutkadim commented 6 months ago

So, now can I compile for windows on MacOS?

DigiEggz commented 6 months ago

So, now can I compile for windows on MacOS?

If you implement those changes, yes. This also helps if you're confused about how to set up your MinGW environment: https://gist.github.com/darmie/99fbd3512b49d0b8cc11fb93bf2b3f8c

DigiEggz commented 6 months ago

Additionally, another user has recently posted a guide on how to compile to Linux from macOS: https://community.haxe.org/t/hxcpp-cross-compilation-macos-to-linux/4104