macos 使用 Mac 进行跨平台开发?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/215099/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using a Mac for cross platform development?
提问by mdec
Who uses Macs for cross-platform development?
谁使用 Mac 进行跨平台开发?
By cross platform I essentially mean you can compile to target Windows or Unix (not necessarily both at the same time). I understand that this also has a lot to do with writing portable code, but I am more interested in people's experience with Mac OS Xto develop software.
通过跨平台,我本质上的意思是您可以编译为目标 Windows 或 Unix(不一定同时)。我明白这也与编写可移植代码有很大关系,但我更感兴趣的是人们使用Mac OS X开发软件的经验。
I understand that there are a range of IDEs to choose from, I would probably use Eclipse (I like the GCCtoolchain) however Xcodeseems to be quite popular. Could it be used as described above? At a pinch I could always virtualise with VirtualBoxor VMware Playeror parallels to use Visual Studio (or dual boot for that matter). Having said that I am open to any other suggested compilers (with preferably an IDE that uses GCC.)
我知道有一系列 IDE 可供选择,我可能会使用 Eclipse(我喜欢GCC工具链)但是Xcode似乎很受欢迎。是否可以按上述方式使用?在紧要关头,我总是可以使用VirtualBox或VMware Player或并行使用 Visual Studio(或双启动)进行虚拟化。话虽如此,我对任何其他建议的编译器持开放态度(最好是使用 GCC 的 IDE。)
Also with the range of Macs available, which one would you recommend? I would prefer a laptop (as I already have a desktop) but am unsure of reasonable specifications.
还有可用的 Mac 范围,您会推荐哪一个?我更喜欢笔记本电脑(因为我已经有了台式机)但不确定合理的规格。
If you are currently using a Mac to do development, I would love to hear what you develop on your Mac and what you like and don't like about it.
如果您目前正在使用 Mac 进行开发,我很想听听您在 Mac 上开发的内容以及您喜欢和不喜欢的内容。
I would primarily be developing in C/C++/Java. I am also looking to experiment with Boostand Qt, so I'm interested in hearing about any (potential) compatibility issues.
我将主要使用 C/C++/Java 进行开发。我也想尝试Boost和Qt,所以我有兴趣了解任何(潜在的)兼容性问题。
If you have any other tips I'd love you hear what you have to say.
如果您有任何其他提示,我很乐意听取您的意见。
采纳答案by Kibbee
Well, using a Mac is just about (discounting OSX86) the only method of actually being able to test on Mac + Windows + Linux all on the same hardware. That being said, I wouldn't go that route if that was your only reason. If you're more comfortable programming in a Windows environment, I would say to do your work in windows, and have a Mac Mini on the side, possibly even a used one you pick up for cheap just to test your software.
好吧,使用 Mac 几乎是(折扣 OSX86)实际上能够在相同硬件上在 Mac + Windows + Linux 上进行测试的唯一方法。话虽如此,如果那是你唯一的原因,我不会走那条路。如果你更习惯在 Windows 环境中编程,我会说在 Windows 中完成你的工作,并在旁边放一台 Mac Mini,甚至可能是你为了测试你的软件而以便宜的价格购买的二手设备。
回答by Stewart Johnson
Eclipse runs on Mac and is well supported. For example, it's the recommended environment for developing for Android on Mac (and all other platforms).
Eclipse 在 Mac 上运行并得到很好的支持。例如,它是在 Mac(和所有其他平台)上为 Android 开发的推荐环境。
XCode is targetted at OS X native development, you may be able to wrangle it in to cross-compilation for Windows but you'd be very much going against the grain.
XCode 是针对 OS X 本机开发的,您可能可以将其与 Windows 的交叉编译进行斗争,但您会非常反对。
I do a little development in XCode but mostly I'm a .NET developer, for which I use VMWare on my Mac. That may sound a bit backwards, but a Windows XP box running on VMWare on the an iMac absolutely flies (I have 4Gb of RAM) and I can create and modify virtual machines for testing (e.g.: Vista, weird Windows XP setups) very quickly. On top of all that, using a Mac day-to-day feels like bliss compared to Windows (I'd never used a Mac until about 15 months ago, I'll never go back to a permanent Windows desktop).
我在 XCode 中做了一些开发,但主要是我是 .NET 开发人员,为此我在我的 Mac 上使用 VMWare。这听起来可能有点倒退,但是在 iMac 上的 VMWare 上运行的 Windows XP 机器绝对能飞(我有 4Gb 的 RAM),我可以非常快速地创建和修改虚拟机以进行测试(例如:Vista、奇怪的 Windows XP 设置) . 最重要的是,与 Windows 相比,每天使用 Mac 感觉就像是幸福(直到大约 15 个月前我才使用 Mac,我永远不会回到永久的 Windows 桌面)。
回答by razong
I have switched to a mac as my main development machine a year ago and never looked back.
一年前我已经切换到 Mac 作为我的主要开发机器,并且再也没有回头。
The one thing I like to mention is, that you write often better software if you develop on more than one platform. From time to time I've found out, that some pieces of code do work on a specific platform and fail on another. Mostly this was due some errors of me instead of software bugs.
我想提到的一件事是,如果您在多个平台上开发,通常会编写更好的软件。我有时会发现,有些代码在特定平台上可以运行,而在另一个平台上却失败了。这主要是由于我的一些错误而不是软件错误。
So in my book - cross platform development enforces more correctness.
所以在我的书中 - 跨平台开发强制执行更多的正确性。
回答by JosephStyons
I use an old Mac Mini at home for Windows development inside a virtual machine. I have had a really good experience with it. If I go full-screen, then it feels just like a desktop - the performance is surprisingly good.
我在家里使用旧的 Mac Mini 在虚拟机中进行 Windows 开发。我有一个非常好的经验。如果我去全屏,那感觉就像是台式机——性能出奇的好。
You may find these posts interesting:
您可能会发现这些帖子很有趣:
Minimum hardware for effective mac development
Mac virtualization: VMWare Fusion or Parallels?
回答by Paul Lefebvre
I do all my cross-platform development on a MacBook Pro, primarily using REALbasic. For testing on Windows and Linux, I use VMware Fusionwhich works well with the remote debugger included with REALbasic.
我在 MacBook Pro 上进行所有跨平台开发,主要使用REALbasic。为了在 Windows 和 Linux 上进行测试,我使用VMware Fusion,它与 REALbasic 中包含的远程调试器配合得很好。
I used to have Boot Campset up with Windows when I was doing .NET-related development. VMware and Parallelsare quite fast, but are no match for natively booting the OS. I haven't had a chance to extensively try MonoDevelopin Mac OS X, but apart from lacking a GUI designer it looks like it might work well and I'll probably look into that for any future .NET projects I may do.
我曾经在进行 .NET 相关开发时使用 Windows 设置Boot Camp。VMware 和Parallels速度非常快,但无法与本机引导操作系统相提并论。我还没有机会在 Mac OS X 中广泛地尝试MonoDevelop,但除了缺少 GUI 设计器之外,它看起来可能运行良好,我可能会在未来的任何 .NET 项目中研究它。
I prefer to have just the one computer that can run all the OSes because it is less space on my desk, less hardware to upgrade and manage and much easier to take all OSes with me.
我更喜欢只有一台可以运行所有操作系统的计算机,因为它在我的办公桌上空间更小,需要升级和管理的硬件更少,而且更容易随身携带所有操作系统。
Any Mac these days can handle running Windows and Linux well enough. The most important thing you need is lots of RAM. Macs nowadays can handle at least 8 GB and I'd recommend that as a starting point (I have 6 GB).
现在的任何 Mac 都可以很好地运行 Windows 和 Linux。您需要的最重要的事情是大量的 RAM。现在的 Mac 可以处理至少 8 GB,我建议将其作为起点(我有 6 GB)。
回答by eyelidlessness
Simply to answer the recommendation question: The new Macbook (low end model) should make an excellent development machine, if you do need a portable. And anecdotally, I used to have a Mac mini, simply because it's what I could afford, and it was excellent for most purposes. I even carried it between home and office (kept another monitor/keyboard/mouse at office, but i do even now that I have a MBP) and it was awesome. I didn't even notice it was in my backpack.
简单回答推荐问题:如果您确实需要便携式电脑,新的 Macbook(低端型号)应该是一款出色的开发机器。有趣的是,我曾经拥有一台 Mac mini,仅仅是因为它是我买得起的,而且它在大多数情况下都非常出色。我什至在家里和办公室之间携带它(在办公室放了另一台显示器/键盘/鼠标,但即使现在我有 MBP),它也很棒。我什至没有注意到它在我的背包里。
Edit: and there's nothing stopping you from double- or triple-booting your Mac, and doing all of your dev in Windows/*nix/OS X on the Mac.
编辑:没有什么能阻止你双启动或三启动你的 Mac,并在 Mac 上的 Windows/*nix/OS X 中完成你的所有开发。
回答by seisyll
If you're looking for a single build system, a Mac is probably your best choice, as you can cross-compile to Windows and Linux using GCC.
如果您正在寻找单一构建系统,Mac 可能是您的最佳选择,因为您可以使用 GCC 交叉编译到 Windows 和 Linux。
- crossgcc.rts-software.orghas gcc toolchains targeting Windows and Linux i386.
- A HOWTOexploring setup of MinGW through MacPorts.
- crossgcc.rts-software.org有针对 Windows 和 Linux i386 的 gcc 工具链。
- 一个HOWTO通过MacPorts的MinGW的探索的设置。
There are compilers that target Darwin/OSX from Linux, but you won't get any of the Cocoa or Foundation libs with that approach. At least with MinGW, you have access to a big part of the Windows platform SDK.
有一些编译器针对 Linux 中的 Darwin/OSX,但您不会通过这种方法获得任何 Cocoa 或 Foundation 库。至少使用 MinGW,您可以访问 Windows 平台 SDK 的很大一部分。
回答by Oli
I'd certainly give Mono a look-in. It has cross-platform bindings for Qt and GTK. You also have access to MonoDevelopwhich is improving in leaps and bounds.
我当然会给 Mono 看看。它具有针对 Qt 和 GTK 的跨平台绑定。您还可以访问正在突飞猛进的MonoDevelop。
If that's of no interest to you, one thing I will mention is that VMWare and Eclipse work well together. VMWare Workstation Professional comes with an Eclipse plugin to allow remote debugging and do multiple-os deployment testing with a couple of clicks. I'd certainly recommend you get the free trial and see if that works for you.
如果您对此不感兴趣,我要提到的一件事是 VMWare 和 Eclipse 可以很好地协同工作。VMWare Workstation Professional 附带一个 Eclipse 插件,允许远程调试并通过几次点击进行多操作系统部署测试。我当然会建议您获得免费试用版,看看它是否适合您。
And a Mac is a great platform to start on. Most things that aren't ported from Linux to run natively run fine on top of X11.
Mac 是一个很好的入门平台。大多数不是从 Linux 移植到本地运行的东西在 X11 上运行良好。
回答by Sherm Pendley
Another option is Cocotron. It runs on Mac OS X, and includes cross-compilers that target Windows, Linux, and Solaris, an Objective-C runtime and portable Foundation framework that works with all three, and an AppKit framework for Windows.
另一种选择是Cocotron。它在 Mac OS X 上运行,包括面向 Windows、Linux 和 Solaris 的交叉编译器、一个 Objective-C 运行时和可与这三者一起使用的可移植 Foundation 框架,以及一个适用于 Windows 的 AppKit 框架。
回答by bastibe
I use my Macs for cross-platform-programming. However, my projects are fairly small and seldomly contain GUIs.
我使用 Mac 进行跨平台编程。但是,我的项目相当小,很少包含 GUI。
I have set up virtual machines to do the compilation. As for IDEs my experience shows that it is often required to have "native" project files to share with other developers. Hence, I primarily develop in XCode and in the end create one project in Visual Studio and a Makefile for Linux. If possible however, I set all the projects up so that they share the source files.
我已经设置了虚拟机来进行编译。至于 IDE,我的经验表明,通常需要有“本机”项目文件与其他开发人员共享。因此,我主要在 XCode 中进行开发,最后在 Visual Studio 中创建一个项目和一个用于 Linux 的 Makefile。但是,如果可能,我会设置所有项目,以便它们共享源文件。
Eclipse projects are fairly compatible for Linux and OSX, but not Windows.
Eclipse 项目与 Linux 和 OSX 相当兼容,但不适用于 Windows。
As others already proposed, I would recommend to use the IDE and OS you are most comfortable with and then port it to the other platforms.
正如其他人已经提出的那样,我建议使用您最熟悉的 IDE 和操作系统,然后将其移植到其他平台。
Depending on the size of your projects I would recommend an iMac or MacBook Pro for cross-platform development. Also, Virtual Machines can be quite demanding, so be sure to get enough ram.
根据您的项目大小,我会推荐 iMac 或 MacBook Pro 进行跨平台开发。此外,虚拟机可能要求很高,因此请确保获得足够的内存。