Can I program for Macs without owning one?

后端 未结 3 1860
悲哀的现实
悲哀的现实 2020-12-19 12:51

I\'m programming a game using C++ and OpenGL/SDL, using Visual Studio as my IDE. I don\'t own a Mac, nor am I even vaguely familiar with the platform. But I want to releas

相关标签:
3条回答
  • 2020-12-19 13:20

    If you're using SDL then the answer is "you can get kind of close to your desire, up to the last step, sort of". Being able to write a game-like program in a single codebase, and then take that codebase to various machines and compile it and have it work is exactly what the Simple DirectMedia Library was designed to do! It wouldn't be very popular if it didn't at least make this a reasonable target.

    That won't mean you'll be able to push a button and get a Macintosh or Linux binary package out of Visual Studio. But you could always find friends and ask them to try the compilation for you on the codebase. So long as you've been careful to only call functions out of the standard C++ library AND stay inside the box that SDL gives you, it should compile fine...in theory.

    Update 2018: - If you want to compile on Mac and don't have one, Travis-CI now has virtualized OS X, so you can run clang and actually have it upload the resulting binaries somewhere. You probably don't want to wait for a full build over the network each time you make a change...but once you get a cross-platform codebase building on OS X, continuous integration can make sure you keep it that way.

    It can be harder in C++ than it is in other languages to make sure you're staying within a "portability sandbox" (especially if you're a beginner). And it can be harder if you're following tutorials targeting Microsoft tools especially, as they have few qualms about advising you to make Windows-only calls in their documentation. So the odds of being able to hand the "fully debugged" code to a friend, have it compile and work on a new platform the first time will be low.

    You'll need a testing period, certainly. And you probably shouldn't wait until the last minute to have someone else make sure the basics are working by compiling it in XCode or whatever. You can lower the risk of writing nonportable code by using the GCC compiler instead, which will be more likely to complain if you start bringing in dependencies that are not actually cross platform.

    It also may be possible to run a "Hackintosh" virtual machine if you like living on the edge. You can certainly make a Linux VM and try building under that, and if it works that will raise the confidence that a Mac build will work too. Won't guarantee it though.

    0 讨论(0)
  • 2020-12-19 13:35

    One option is to use Java. If you combine that with the eclipse RCP SWT widgets, you can target Win/Linux/OSX with a native LAF. You'd probably want to use eclipse as your IDE.

    If you really must use c++, you could aim at wxWidgets or some other cross-platform widget set, but compiling is really going to require a copy of all of the OSX libraries and a compiler set that knows how to target the platform/linking.

    I'd really recommend the Java route if you don't want to own any sort of Apple hardware...much less painful. Beside, with the plethora of JVM supported languages, you don't even have to write in Java...try Scala!

    0 讨论(0)
  • 2020-12-19 13:41

    Firstly you can't cross-compile for a Mac. You will need their "gcc". The Mac Universal binary can be created (theoretically) on a PC, but practically its not possible yet.

    VS2010 cannot compile for Mac, although if you're going to use a different language perhaps then you can code for Macs(such as in Python).

    Any cross platform languages will help. Python, Java, Ruby, Perl

    0 讨论(0)
提交回复
热议问题