Can I program for a Mac without owning it?

I am programming a game using C ++ and OpenGL / SDL using Visual Studio as my IDE. I don't have a Mac, and I'm not even vaguely familiar with the platform. But I want to release for Mac users anyway.

I have three questions. Can I write and compile Mac programs on a PC? If I can, are there any possible obstacles to this? And finally, can VS2010 compile a Mac, or will I need to use a different compiler?

+4
source share
3 answers

If you are committed to using Visual Studio and C ++, then people can advise you to abandon this restriction ("do not write in C ++, make it an HTML5 web page, and it can work anywhere, even on the iPhone!"). Or they may indicate why your question is not being answered. or , they can correctly answer your question (what is the concept !: -P)

If you use SDL, then the answer will be "you can get closer to your desire, up to the last step, kind of." The ability to write a game program in one code base, and then take that code base to various machines and compile it and make it work - this is exactly what the Simple DirectMedia Library was designed to do! It would not be very popular if it would not make it a reasonable target.

This does not mean that you can click the button and display the Macintosh or Linux binary package from Visual Studio. But you can always find friends and ask them to try compilation for you on a code base. As long as you were careful to call functions only from the standard C ++ library and stay inside the box that the SDL gives, it should compile ... theoretically.

"In theory, there is no difference between theory and practice. In practice, there is." - YogiBerra

In C ++, it can be harder than in other languages ​​to make sure you are in the "sandbox for portability" (especially if you're a beginner). And it can be harder if you follow tutorials that focus on Microsoft tools, especially since they have little doubt that you are advised to make Windows-only calls in their documentation. Thus, the likelihood that you will be able to pass the "fully debugged" code to a friend, compile it and work on the new platform for the first time will be low.

Of course, you will need a testing period. And you probably shouldn't wait until the last minute for anyone else to make sure that the basics work by compiling them in Xcode or something else. You can reduce the risk of writing non-portable code by using the GCC compiler instead, which is more likely to complain if you start creating dependencies that are not really cross platform.

It may also be possible to run the Hackintosh virtual machine if you enjoy living on the edge. Of course, you can create a Linux virtual machine and try to build it under it, and if it works, it will increase the confidence that the Mac build will work. However, this does not guarantee.

+6
source

First, you cannot cross-compile a Mac. You will need their "gcc". The binary Mac Universal can be created (theoretically) on a PC, but practically it is not yet possible.

VS2010 cannot compile for Mac, although if you intend to use a different language, maybe then you can code for Mac (for example, in Python).

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

+3
source

One option is to use Java. If you combine this with the eclipse RCP SWT widgets, you can configure Win / Linux / OSX to local LAF. You might want to use eclipse as your development environment.

If you really have to use C ++, you can focus on wxWidgets or some other cross-platform widget set, but compilation really needs a copy of all OSX libraries and a set of compilers that knows how to target platform / links.

I would recommend the Java route if you don't want to own any Apple hardware ... much less painful. Also, with many supported JVM languages, you don’t even have to write in Java ... try Scala!

+2
source

Source: https://habr.com/ru/post/1440443/


All Articles