c++buildvisual-studio-2019exedmg

How to build c++ code into a .dmg file rather than a .exe file on visual studio 2019 from a windows computer?


How would I build my c++ code into a dmg file other than a exe file which is what it always builds into. I am trying to make my programs useable by mac users but I cant find answers for this


Solution

  • First off, .dmg on Mac isn't an executable. It's really a packaging tool that includes your executable. If you have a GUI, then what you really need to produce is a .app. If it's just a command line tool, then a binary, just like on Unix. Remember, OSX is very UNIX-like.

    I did a Google for "cross compile on windows for mac". Google gave me a bunch of links that go the other way, but if you wade through it, you might find something useful. Depending on what you're building, this is interesting:

    https://metricpanda.com/rival-fortress-update-11-cross-compiling-for-three-platforms/

    However, if you're trying to write GUIs, you almost certainly need the Mac-specific libraries to link against, and you don't have them.

    You MIGHT be able to cross-compile if you switch to Qt as your build environment. I haven't tried that.

    If I were going to do this, though, I'd build on Mac. You have to test, anyway, right?