This question contains various sub-questions within description which I hope will help me eventually achieve the described objective. The question’s description will evolve depending on requested information or evolution of answers.
I made this C++ server for a game, which works on Windows, and would like to make it cross-platform, so it at least works on Linux (Ubuntu), macOS would be a plus i’d really appreciate, but not indispensably necessary (specially if single “cross-platform executable” isn’t a possibility).
The server was programmed using VisualStudio IDE. These are all my source files I copied to another directory, including a custom static library (this one is in the same directory, the rest are all in C:/libraries):
Project dependencies are the following as configured in VisualStudio:
All libraries are to be linked statically. These are the ones my server uses:
- GLM: Header only, cross platform.
- Cereal: Header only, cross platform.
- SFML modules: Can be linked statically. Cross platform according to them, even though this surprises me, since, for example, sfml_network module depends on winsock, which is a windows library…
- MORPH_Shared_functions, My own library: Is static. It’s own dependencies are the same as already listed for server, so I’m asuming that would make it cross-platform.
The entire server seems to fit in a single executable without dynamic library dependencies. (will confirm if I can simply move it to my laptop and it still works without any libraries installed in the system)
For starters I tried the g++ compiler for Ubuntu. I installed it on windows by installing MinGW, and now I can use it from windows’s cmd. I tried following this nice and simple guide: https://courses.cs.washington.edu/courses/cse373/99au/unix/g++.html
I’ll go more in-depth in what went wrong with this approach if requested, but I basically didn’t manage it yet due errors derived from command arguments complexity.
I imagine if I continued with this approach (which works for ubuntu, and no other OS’s I know of), I’d first try to get the command right for compiling, and then I could try making visual studio compile with CMake using that same command, or something like that? I don’t know too much about cmake, I only used it for compiling some libraries like sfml a few times.
Besides, maybe there’s a way I can get a single “cross platform executable” for the 3 OS’s? Or would that be asking for too much?
Note: I already did a similar question some weeks ago. This one is based on the same issue, but with a specific project case, and some actual strategies already developed.