-2

I wrote a small program in C using SDL2. I'm used to only writing tools for myself and building them on Linux systems, but a friend of mine asked if I could give him a copy for use on his Windows machine.

My program is built using cmake, and I could theoretically build it from source on his machine. However, I would really like to know how more professional people distribute their apps.

I imagine that it's more involved than just compiling the program using gcc and then distributing the generated .exe file.

pjs
  • 18,696
  • 4
  • 27
  • 56
Dan
  • 1
  • 4
  • 1
    You either build it for every target architecture and package it in a format that is expected by that architecture/distribution (rpm, deb, etc for different Linux flavors, windows installer for windows), or you distribute it as a portable source code with appropriate build scripts/makefiles and require a specific build environment to be present on the targets. – Eugene Sh. Apr 28 '23 at 16:14
  • More professional people will buy a Windows computer for compiling and testing on Windows. Small open-source projects rely on at least one volunteer having a Windows computer to compile and test on - if nobody does, then it doesn't get done. – user253751 Apr 28 '23 at 16:15
  • @user253751 Well, one can get away with a virtual machine... Or dual boot – Eugene Sh. Apr 28 '23 at 16:16
  • Way too broad as-is. Narrow it down to something like "How can I cross-compile a SDL app to Windows from Linux with CMake?" Even that would probably be too broad, come to think of it. Figure out a procedure you like for doing that and if you run into problems, ask a question about *those* problems. – genpfault Apr 28 '23 at 16:16
  • This is not a good question for Stackoverflow but I suggest searching for "Windows application packaging" on Google/Bing. There's ton of information on how to do this using different methods. – karlphillip Apr 28 '23 at 16:28

1 Answers1

-2

You asked how professional developers compile programs for Windows.

Typically, they will buy a Windows computer, or install Windows in a virtual machine (virtual computer). They will use that computer for compiling and testing on Windows, using the relevant Windows tools like Microsoft Visual C++.

Small open-source programmers who don't have Windows and don't want to buy it just for testing can will rely on some volunteer who already has Windows on their computer. If nobody volunteers, then it doesn't get done. That's the nature of open-source: if you want it and nobody else has done it, you have to do it yourself.

It's possible to compile Windows programs on Linux*, so why is it important to have a Windows computer? It's for testing. No matter how hard you try, there's always going to be a chance that for some silly reason your program doesn't work on a real Windows computer, so you need to try it and see. You wouldn't write a Linux program, compile it and give it to someone else without running it for yourself first to make sure it works - and the same applies for Windows.

Every release of a professional product is thoroughly tested on every operating system where it's supposed to work. For free and open source products, the expectations are much lower, and it's quite common for the developer to not make a Windows version at all, or make it someone else's problem - including the possibility of compiling one but not really caring whether it actually works or not. Therefore you may choose not to bother testing every version your program on Windows except when someone complains that it doesn't work, if that's what you want to do. However, I'd say it's a bit pointless to compile one and then not test it even a single time as there's a very high chance it won't work. So you still need to test at least once.

* by installing a Windows compiler on Linux, e.g. see How to compile for Windows on Linux with gcc/g++?. Visual C++ will not work on Linux, but you can use the Windows version of gcc, called MinGW.

user253751
  • 57,427
  • 7
  • 48
  • 90
  • Thank you very much @user253751! I appreciate that you took the time to answer my broad question. I have access to a Windows 11 machine, if I compile the program successfully on that machine, am I able to distribute it to any Windows 11 machine? – Dan Apr 28 '23 at 16:28
  • @Dan as far as I know. You may have a couple of hiccups, like, I *think* the Debug version of Visual C++ compiles things with debug libraries that aren't there if you don't have Visual C++ installed. But you'd quickly find that out by *trying it* and then googling the error message – user253751 Apr 28 '23 at 16:29