9

I'm new in here and I still don't have a lot of experience and knowledge about Linux and software development.

I was thinking to start learning software and game development and I am currently building a PC in order to do that. I want to develop software or a game that has support with three major platform (Windows, macOS, and Linux).

Can I smoothly develop software or a game that support three major platforms from only one OS? Like if I use one Linux (with a lot of development tools in there) and want to develop software or game that also support Windows, macOS, and other Linux distribution, can I do that without facing a problem at later time like switching OS back and forth in order to testing it work or not? Or do I just need to install all the OSes (with all of the development tools in each OS) and build them in each OS for each support?

12
  • 3
    @Archemar um no, it's not "quite a challenge", at least for you now that I can show you how to do it in a single line: sudo dnf install -y mingw64-gcc; export CC=x86_64-w64-mingw32-gcc; echo '#include<stdio.h>' > helloworld.c ; echo 'int main() { printf("hello world\\n"); return 0;}' >> helloworld.c; $CC -o helloworld.exe helloworld.c (Of course, how you install mingw64-gcc depends on your distro, but the rest will be identical) Apr 13, 2023 at 11:48
  • 1
    @PhilipCouling well, it again depends on your distro, but Fedora and similar have a relaviely nice selection of mingw development libraries your can just install; for example, getting mingw64-building Qt6 is one DNF command away. Same for things like all the classical boost, zlib, SDL, GTK, … libraries: prepackaged. If not, still just a normal build away, where you point the configuration script of whatever library at the mingw compilers and binutils. Apr 13, 2023 at 12:03
  • 2
    You might want to take a look at godot, an open-source cross-platform game development engine that you can use to write 2D & 3D games that target Windows, Max, Linux, and mobile devices from the same code base. There are lots of tutorials available in blog posts and youtube videos.
    – cas
    Apr 13, 2023 at 14:02
  • 3
    @PhilipCouling You don't need the actual DLLs from Microsoft to be able to build a binary which links to them. MinGW comes with a full set of Win32 headers and import libraries (your distribution likely has packages like mingw32-headers and mingw32-crt), so the compiler will just grab symbol stubs from its bundled libadvapi32.a and produce a binary which will depend on an actual advapi32.dll to run.
    – TooTea
    Apr 13, 2023 at 20:06
  • 1
    Minecraft Java edition is one example of a game that works on all platforms with no modifications.
    – slebetman
    Apr 14, 2023 at 3:04

5 Answers 5

13

Yes, of course, you can.

To do that, you need a universal language which can be understand on all target machines. Once you have such language - write a software on it, without using OS-specific code and you are done.

And guess what - there are tons of such languages, starting from C, C++, Java, and many-many more. And you can also use a multi-platform frameworks (language plus set of libraries and tools) to do a multi-platform projects.

What is even better, there are frameworks designed for multi-platform creation of games. The top on this list currently held by Unity. It would give you a lot of game-specific functionality and support for almost all modern OS's. Win/Max/Linux - in a free version of Unity, plus a dozen of other (including XBox/PlayStation/etc) in a commercial version.

14
  • 29
    Defining C / C++ as universal languages is a bit misleading. The core language is universal, that's what C was designed to be. However no practical C program truly exists without interaction with the OS and Windows has never had any real overlap with Linux there. Compiled C programs are not portable between OS and cross compiling for Windows on a Linux platform is tricky. This is quite different to Java where the "compiled" program runs on a "JVM", and the OS specific JVM [Java virtual machine] provides OS specific boiler plate to allow one program to run. Apr 13, 2023 at 11:55
  • 2
    @Philip Couling: this is why a framework like Unity is recommanded here. With Qt you can also have a platform independent program (tested when using a program made for MacOS and compiled on Windows and on Linux). Apr 13, 2023 at 12:08
  • 1
    @PhilipCouling, As I said already "without using OS-specific code". Of course writing multi-platform on C is tricky and not for a weak of heart. But it is still doable. Take SDL for example, and you can have almost as many OSes covered as with Unity.
    – White Owl
    Apr 13, 2023 at 12:15
  • 1
    @WhiteOwl it's honestly that the most code people write these days is fairly platform agnostic – think about it: the whole glibc is tiny compared to say the whole of firefox. As consequence, software vendors spend sufficient time on their frameworks so that they performantly abstract away most of the system. The part of functionality of say a web browser, letter editor, 3D game or enterprise payroll and reimbursement system that really needs to deal with the nitty-gritties of each OS is really small, compared to what the development effort and code amount of the actual logic is. Apr 13, 2023 at 19:25
  • 10
    I think this answer is missing a major sticking point though. Without at least VMs of the other environments (Windows and MacOS) it is going to be impossible to test on those systems. That is a recipe for disaster. Anyone developing cross-platform should have some kind of access to all the environments they plan to release on. The question asks if they need that specifically. Apr 13, 2023 at 21:40
8

The answer by @WhilteOwl is very nice, and I'd like to make some addition.

You can also try to learn HTML5/ES6/CSS3, which are Web programming technologies. You can use these to develop a kind of cross-platform software, that can run on desktop, tablet, TV set and hand-held devices.

You can host it on the web to save users from downloading stuff, and there's the ElectronJS Framework that you can use to build executables.

HTML and JavaScript have what I consider the easiest learning curve, although, back-end secure programming is a tough topic.

H5 ecosystem has more free reusable components than Unity I believe, and developing for this platform definitely doesn't require using proprietary tools.

Simple 2D games can be developed using Canvas API, and 3D games have WebGL and WebGL2 for support. There are also frameworks such as Three.js.

0
4

White Owl's answer, unfortunately, is overly optimistic. In theory, this is how things should work. In practice, it just isn't the case - or, at least, it is only so to a certain extent. There are numerous little problems and rabbits holes that await you if you attempt cross platform development.

For example, .NET is supposed to be cross platform, yet it doesn't support native GUI app development on Linux. Blazor should in theory work, yet I used to encounter Linux specific bugs. Also forget about Visual Studio, you only get Visual Studio Code, which is less feature packed and less convenient to set up.

To say that C and C++ are platform independent is... well, even less true. Philing Couling commented that:

Defining C / C++ as universal languages is a bit misleading. The core language is universal, that's what C was designed to be. However no practical C program truly exists without interaction with the OS and Windows has never had any real overlap with Linux there.

Even the core language is not fully universal, given differences in implementation defined behavior.

You can certainly try cross platfom development - but be wary of subtle problems that may and most likely will appear from time to time.

3

Windows, MAC and Linux are very different. Modern macOS (formerly known as OS X) does have some Unix-like roots, but it's whole GUI infrastructure is very different from that used on a typical Unix-like system.

There are languages and frameworks that try to abstract over the differences between operating systems, but those abstractions are not perfect. If you write a non-trivial program then it is very likely you will encounter bugs that only manifest themselves on a subset of target platforms, that you will have to write platform specific code to perform some operation that your framwork does not provide a cross-platform interface for or that you will want/need to use a library outside your framework that requires platform-specific techniques to interface with your framework.

0

Yes, this is possible, as the other answers indicate.

What I'd like to add is that when developing a game, you are going to rely on a whole stack of software: you will be using one or more programming languages and software libraries and frameworks that implement basic functionality you want to use but not implement yourself.

Many of these stacks are suitable for cross-platform development, and you will need to pick one, depending on

  • hardware you want the game to run on (laptops? phones?)
  • the software environments you want it to run on (web-based? native GUI? text-based? should it be scriptable? etc.)
  • aesthetic and functional requirements you want the game to meet
  • performance requirements (easy to meet for tic-tac-toe, not so easy for a chess server with millions of users or for a first-person shooter)
  • your own experience

I think the best approach is hands-on:

  • find one or more open source games that look like games you'd want to spend time working on, and that are offered for Windows, MacOS, and Linux
  • figure out what it would take to develop and contribute a small improvement

That will take you through the whole software stack, build process, development process, and project communication requirements. Once you have an idea of what's required to make one tiny change to the kind of game you'd be interested in working on, you will have some perspective on what it would take to develop such a game.

Personally I've only contributed a few lines of code to only one game, namely Freeciv, which runs natively on Linux, Windows, MacOS, Android, and a few other OSes, and also has a web-based version. That is just one example; just Google for examples of multiplatform games and you'll probably find a few that look like the kind of game you'd want to work on.

Not the answer you're looking for? Browse other questions tagged .