如何使用 mac os 10 上的终端编写和编译 c++代码?
如何使用 mac os 10 上的终端编写和编译 c++ 代码? 我有一台带有 Power PC 芯片/带有 leopard 的 Power Mac。
how do you use the terminal on mac os 10 to write and compile c++ code?
I have a power mac with the power pc chip/with leopard.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,确保您已安装Apple 开发者工具。如果您不想下载,它们也可能位于您的 Mac OS X 安装盘上。 (尽管您可能会得到旧版本)之后,
cd
到您的代码所在位置并执行类似的操作:然后您可以像这样运行它:
First, make sure you've got Apple's developer tools installed. They may be on your Mac OS X install disk as well, if you don't feel like downloading. (although you may get an older version) After that,
cd
to where your code is and do something similar to this:You can then run it like this:
Mac 附带的最简单的文本编辑器是
nano
。这是不言自明的。保存源文件后,只需运行g++ my_source_file.cpp -o my_program_name
即可编译。不过,我建议使用 XCode IDE。旧版本 3.2 的下载量为 600 MB,新版本 4.0 的下载价格为 5 美元。尽管它不是最好的,但与从头开始学习命令行相比,使用它会更好。如果您首先使用 Apple 的安装程序安装编译器,那么您就已经拥有它了。
The simplest text editor included with Mac is
nano
. It's pretty self-explanatory. Once you've saved the source file, just rung++ my_source_file.cpp -o my_program_name
to compile.However, I recommend using the XCode IDE. The old version 3.2 is a 600 MB download, or the new 4.0 is $5. Even though it's not the best, you will have a much better time with it than learning the command line from scratch. And if you install the compiler using Apple's installer in the first place, you already have it.