1

I'm using Fedora 29, and I've been happily using sublime text to compile/build and run C++ code that runs on this machine.

I now realize that the compiled program is not portable. It will only run on Linux. It won't run on Mac or Windows.

After some research, I found out that Mac uses a different format than Linux does. This info was backed up after repeating the experiment as well as compiling the same source code on Mac (which worked fine).

Question

Is there a way to use sublime text on Linux to compile code (C++ or other) that will run on other operating systems (i.e MacOS and Windows). I do not mind compiling the code 3 times, one for Windows, one for Mac, and one for Linux.

Notes

Note1: I want the code to be compiled in C++11!

Note2: I have already added the C++11 build, and have been using it.

Edit

My post is different from this question here, because I already know why I need to compile in different formats, therefore that is not my question. My question is "how can I do this in sublime text?" or, if that is not possible, "is there an app that will let me do this without leaving my OS?" Thanks in advance! PS: I do not mind compiling the code 3 times, one for Windows, one for Mac, and one for Linux.
Why do we need to compile for different platforms (e.g. Windows/Linux)?

jwpfox
  • 5,124
  • 11
  • 45
  • 42
  • 3
    Search for "cross-compiler" - although building on Linux for Mac seems like it'll just be fraught with problems if it's even possible... typically you'll have a build server of the proper target architecture and OS. Is that something you can do? Recall how when you download software from the web you need to get a specific build for your specific platform. – Lightness Races in Orbit Jan 08 '19 at 15:46
  • Okay, thanks. I'll look for one. – Dash Conroy Jan 08 '19 at 15:47
  • Possible duplicate of [Why do we need to compile for different platforms (e.g. Windows/Linux)?](https://stackoverflow.com/questions/48235579/why-do-we-need-to-compile-for-different-platforms-e-g-windows-linux) – Aykhan Hagverdili Jan 08 '19 at 16:41
  • Cross-compiling is difficult at best and impossible at worst -- if you need to compile for another OS, it's much easier to just run that OS (either on a separate machine, or in a virtual machine) and compile natively there. (in the virtual machine case, you can even set up a virtual shared drive so that you can still edit on your host OS's text editor before compiling on the guest OS) – Jeremy Friesner Jan 09 '19 at 06:47
  • Oh, okay. I've been thinking of that. Thanks for the help. I think this question has been officially answered now, but: 1-Can you tell me how to do the shared hard drive? Should I just use a shared folder in virtual box? 2-Is it even possible to have a VM of OSX? Is it open source? – Dash Conroy Jan 09 '19 at 14:32

0 Answers0