Mac 上的 c++ 开发
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2352235/
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
c++ development on Mac
提问by amit
I have till now mainly concentrated on web programming thus far and now want to enter application programming space. I use a mac, and wanted to know what sort of compilers, IDEs etc people generally use for c++ dev.
到目前为止,我主要专注于网络编程,现在想进入应用程序编程领域。我使用 mac,想知道人们通常为 c++ 开发使用什么样的编译器、IDE 等。
extremely n00bOne more thing immensely bothering me was the fact that c++ compilers generally output .exe
which can't be used on macs. I need to understand basic OOP programming fundamentals and thought c++ would be the best choice. Please suggest something.
非常n00b另一件让我非常困扰的事情是,c++ 编译器通常会输出.exe
无法在 mac 上使用的输出。我需要了解基本的 OOP 编程基础,并认为 c++ 将是最佳选择。请提出一些建议。
采纳答案by Hassan Syed
C++ is not restricted to .exe files.... window PE files are one container format for machine code. A C++ binary can be encased in any low-level container format you can think of.
C++ 不限于 .exe 文件......窗口 PE 文件是机器代码的一种容器格式。C++ 二进制文件可以封装在您能想到的任何低级容器格式中。
Objective-C on the mac can be a very pleasant language to learn, also Java. Do you really need to learn C++ at this junction ? C++ is suited to low-level programming problems -- i.e., video games, system software, and generally performance-critical software (photoshop and imovie).
mac 上的 Objective-C 是一种非常有趣的学习语言,Java 也是。你真的需要在这个路口学习 C++ 吗?C++ 适用于低级编程问题——即视频游戏、系统软件和一般性能关键的软件(photoshop 和 imovie)。
回答by Partial
Compiling C++ on a certain operating system (OS) will create an executable file for that OS. You are not limited to only a .exe binary file.
在某个操作系统 (OS) 上编译 C++ 将为该操作系统创建一个可执行文件。您不仅限于 .exe 二进制文件。
The first step to start creating your first C++ application is to install Xcode. This development program is not installed by default with Mac OS X. You must insert one of the DVDs that came with your computer and install it. After, start Xcodeand click on Fileand then New Project. Once that is done, select Command Line Tooland make sure that C++ stdc++is the selected type. Before I forget to write this, Xcode's compiler for C++ is gcc. If you need some help to start off you always visits some sitesor buy (or rent) some books.
开始创建第一个 C++ 应用程序的第一步是安装Xcode。Mac OS X 默认不安装此开发程序。您必须插入计算机附带的 DVD 之一并安装它。之后,启动Xcode并单击File然后单击New Project。完成后,选择命令行工具并确保C++ stdc++是所选类型。在我忘记写这个之前,Xcode 的 C++ 编译器是gcc。如果您需要一些帮助才能开始,您总是访问一些网站或购买(或租用)一些书籍。
One thing to note is that Apple's main programming language is Objective-C which is different from C/C++. While both of these languages have common features, it might be easier to start with Objective-C. It is possible to do some OOP with Objective-Cand it will be easier with it. On the other hand, it is possible to do more complex OOP with C++ than with Objective-C.
需要注意的一点是,Apple 的主要编程语言是 Objective-C,它不同于 C/C++。虽然这两种语言都有共同的特性,但从 Objective-C 开始可能更容易。可以用 Objective-C做一些OOP,而且使用它会更容易。另一方面,与使用 Objective-C 相比,使用 C++可以执行更复杂的 OOP。
If you ever wish to learn the basics of the Cocoa Framework (which is a set of libraries and tools to help you create a window), I suggest you learn how to program (some Objective-C or C++ could be nice) and buy the book Cocoa Programming for Mac OS Xfrom Aaron Hillegass.
如果你想学习 Cocoa 框架的基础知识(它是一组帮助你创建窗口的库和工具),我建议你学习如何编程(一些 Objective-C 或 C++ 可能很好)并购买来自 Aaron Hillegass 的书籍Cocoa Programming for Mac OS X。
回答by Stefan Arentz
If your question really is: can I use C++ to develop Mac applications, then the answer is yes, but for true native Mac applications you probably want to invest in learning Objective-C and the Cocoa frameworks.
如果您的问题确实是:我可以使用 C++ 来开发 Mac 应用程序,那么答案是肯定的,但是对于真正的原生 Mac 应用程序,您可能想要投资学习 Objective-C 和 Cocoa 框架。
回答by sfg
A c++ compiler will output object code that should be native to the platform the compiler is built for. So on a mac it will output executable programs that will work on a mac, not windows executables.
C++ 编译器将输出对象代码,这些代码应该是编译器所针对的平台的本机代码。因此,在 mac 上,它将输出可在 mac 上运行的可执行程序,而不是 windows 可执行文件。
XCode is a well regarded mac IDE that you can use for C++ development.
XCode 是一款备受推崇的 Mac IDE,可用于 C++ 开发。
Java may be an easier choice for OOP as it avoids many pitfalls that can catch out novices. Another OOP alternative is Objective-C which is a good choice for mac development.
Java 可能是 OOP 的一个更简单的选择,因为它避免了许多可能会抓住新手的陷阱。另一种 OOP 替代方案是 Objective-C,它是 mac 开发的不错选择。
回答by Joan P.S
You also can use QT Creator which is a really nice IDE :)
你也可以使用 QT Creator,这是一个非常好的 IDE :)
回答by D.C.
Just use xcode / gcc to create and compile C++ applications on your mac. Native Mac applications are most commonly coded in objective-C, but since the mac is a variant of bsd, using gcc tools to create a c++ executable is also common.
只需使用 xcode / gcc 在您的 mac 上创建和编译 C++ 应用程序。原生 Mac 应用程序最常使用 Objective-C 编码,但由于 mac 是 bsd 的变体,因此使用 gcc 工具创建 c++ 可执行文件也很常见。
edit: to clarify: - xcode is the free Mac IDE that comes on the install disk - gcc is the open source compiler. it is part of Xcode.
编辑:澄清: - xcode 是安装盘上的免费 Mac IDE - gcc 是开源编译器。它是 Xcode 的一部分。
回答by Jesper Fyhr Knudsen
If you are using a Mac Xcode
is the way to go, there are of cause others out there, like Net Beans
and Eclipse
如果您使用的是 Mac Xcode
,那当然有其他原因,例如Net Beans
和Eclipse
回答by tyblu
Comparison of integrated development environments - C/C++ http://en.wikipedia.org/wiki/Comparison_of_integrated_development_environments#C.2FC.2B.2B
集成开发环境对比——C/C++ http://en.wikipedia.org/wiki/Comparison_of_integrated_development_environments#C.2FC.2B.2B
I use Code::Blocks with gcc and a GNU toolchain for embedded development on a Mac.
我将 Code::Blocks 与 gcc 和 GNU 工具链一起用于 Mac 上的嵌入式开发。
回答by Unicorn
If you are intended to build applications for MAC then best way is to learn "Objective C" and use Xcode editor on MAC. This will help you in long term as well. Xcode also allows you to build application using C/C++ and java, along with objective C.
如果您打算为 MAC 构建应用程序,那么最好的方法是学习“Objective C”并在 MAC 上使用 Xcode 编辑器。从长远来看,这也会对您有所帮助。Xcode 还允许您使用 C/C++ 和 java 以及目标 C 构建应用程序。
A good way to start can be visiting this URL http://developer.apple.com/mac/, It has help also avail.
一个很好的入门方法是访问这个 URL http://developer.apple.com/mac/,它也有帮助。