如何从 Xcode 5.02 运行 C++

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21419659/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 04:36:08  来源:igfitidea点击:

How to run C++ from Xcode 5.02

xcodexcode5

提问by Trying_hard

I haven't used Xcode in awhile and overall new to macs. How od I run a C++ program from Xcode V5.02. I don't see a command line function anymore?

我有一段时间没有使用 Xcode,对 mac 来说总体上是新手。我如何从 Xcode V5.02 运行 C++ 程序。我再也看不到命令​​行功能了?

采纳答案by virindh

Xcode supports c++ in objective-cprojects through .mmfiles, but not on its own.

Xcodeobjective-c通过.mm文件在项目中支持 C++ ,但不支持 C++ 。

UPDATE: Guess I was wrong, see here: http://neilmonday.blogspot.com/2008/02/how-to-compile-basic-c-programs-in.htmland here: How do I create a new C++ project in XCode?

更新:我猜我错了,请看这里:http: //neilmonday.blogspot.com/2008/02/how-to-compile-basic-c-programs-in.html和这里:如何创建一个新的 C++ 项目在 XCode 中?

Run xcode-select --installto make sure you command line tools installed on the system.

运行xcode-select --install以确保您在系统上安装了命令行工具。

回答by Samuel Noyes

In Xcode, select File>New>Project. Then navigate to the Application tabunder OS X. The last choice will be "Command Line Tool". Hit Next. Then, select C++in the type pulldown menu at the bottom. Name your project, hit next, choose a place to save, and click Create. You will see a file called main.cpp. Select it, and you're ready to go!

在 Xcode 中,选择File>New>Project。然后导航到OS X 下的应用程序选项卡。最后一个选择将是“命令行工具”。点击下一步。然后,在底部的类型下拉菜单中选择 C++。为您的项目命名,点击下一步,选择一个保存位置,然后点击创建。您将看到一个名为 main.cpp 的文件。选择它,您就可以开始了!

回答by zaph

See this SO answerfor help with command line tool installation.

有关命令行工具安装的帮助,请参阅此 SO 答案

Basically the terminal

基本上是终端

command is

命令是

xcode-select --install

xcode-select --install

The other option is to create a C++ Command Line tolls project.

另一种选择是创建一个 C++ 命令行收费项目。