I followed a tutorial to build a snake game in Rust with PistonWindow.
I would like to produce a build file for mac, windows, and linux respectively, so that I can send someone the file and they could download and double click to play the game.
I see the executable file in /target/debug, however when I double click that on my mac I get an 'The application "terminal" is not open anymore' error message. Is this an issue specific to my code, or my use of cargo run/build?
My background in building desktop applications is from writing Electron Apps with javascript. I searched around a good little bit and have not found my answer.
On macOS, full-fledged GUI apps are more complicated than a single executable. In order to make a properly functioning application, you'll need to create a so-called app bundle, with an Info.plist file, the executable, icons, dependence libraries, etc. all in the correct folder structure. You can probably hack your way around that but you really shouldn't.
You generally need to package macOS applications for distribution. This is most important when the app needs to be shipped with dylib dependencies and other resources. Running an executable from the terminal on macOS has some "non-standard" behavior, but it can work well enough for developers. For users, you're going to want an app bundle.
cargo-bundle can be used to build installers for various platforms.
For distribution in the Apple app store, the app must be signed, but that doesn't appear to be supported by cargo-bundle yet.
Cross compiling can be very annoying because you will usually have to install a compiler toolchain for your target. E.g. for cross-compiling on a macOS host to Windows you will need MinGW installed on the Mac.
If you really want to get into cross compiling, your best bet is probably trust.
So, not as important for this project, but then say I were to create a desktop application and wanted to offer it for linux, windows and mac. What is the common approach? And what are the options in the context of Rust?
Is an installer compiling the application from source on the users device to avoid the issue you are describing with cross compiling?
No, the trust repo shows how your CI pipeline can build releases on the various systems. There's no cross compilation involved, since CI runs the compiler on each host OS. The only thing the user needs to do is download whatever binary or installer your CI pipeline produces for their system.