如果没有Mac,可以为Mac编程吗? [英] Can I program for Macs without owning one?

查看:136
本文介绍了如果没有Mac,可以为Mac编程吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Visual Studio作为我的IDE使用C ++和OpenGL/SDL编写游戏.我没有Mac,甚至对这个平台也不太熟悉.但是我想向Mac用户发布所有内容.

我有三个问题.我可以在PC上编写和编译Mac程序吗?如果可以的话,这样做有什么陷阱吗?最后,VS2010可以在Mac上编译,还是需要使用其他编译器?

解决方案

如果您使用的是SDL,那么答案是您可以接近自己的愿望,直到最后一步,都可以."能够在单个代码库中编写类似游戏的程序,然后将该代码库带到各种计算机上并进行编译,使其运行 正是Simple DirectMedia库的设计宗旨! 如果它至少没有使之成为合理的目标,那将不会很受欢迎.

那并不意味着您将能够按一个按钮并从Visual Studio中获取Macintosh或Linux二进制程序包.但是您总是可以找到朋友,并要求他们在代码库上为您尝试编译.只要您一直谨慎地只从标准C ++库中调用函数并留在SDL为您提供的功能之内,它就可以很好地编译...理论上.

更新2018年-如果要在Mac上编译而不使用它,则Travis-CI现在具有

当然,您需要一个测试期.您可能不应该等到最后一刻才让别人通过在XCode或其他任何方式中进行编译来确保基础工作正常.您可以改用GCC编译器来降低编写不可移植代码的风险,如果您开始引入实际上不是跨平台的依赖项,则更有可能抱怨.

如果您愿意,还可以运行"Hackintosh" 虚拟机在边缘.您当然可以制作一个Linux VM并尝试在该Linux VM下进行构建,如果它可以运行,那将增加Mac操作系统也可以运行的信心.虽然不能保证.

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 release to Mac users all the same.

I have three questions. Can I write and compile Mac programs on a PC? If I can, are there any possible pitfalls to doing so? And finally, can VS2010 compile for Mac, or will I need to use another compiler?

解决方案

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.

这篇关于如果没有Mac,可以为Mac编程吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆