如何在 Xcode 4 中运行 C++ 程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7911076/
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
How do I run a C++ program in Xcode 4?
提问by ObscureRobot
I want to write a C++ program in Xcode on my Mac. I wrote this basic one to test it. When I build, I get a "Build Successful" message.
我想在我的 Mac 上用 Xcode 编写一个 C++ 程序。我写了这个基本的来测试它。构建时,我收到“构建成功”消息。
However, I cannot run it! If I hit Command+R nothing happens. When I go to Project->Run the Run option is disabled.
但是,我无法运行它!如果我按 Command+R 没有任何反应。当我转到 Project->Run 时,Run 选项被禁用。
#include <iostream>
using namespace std;
int main()
{
cout << "helo" << endl;
}
回答by ObscureRobot
- Launch XCode
- In the "Choose template" box, pick Mac OS X, then Command Line Tool. Press Next
- Give your project a name, select C++ as the type
- You should see a new project with main.cpp
- press the Run button
At the bottom of the screen, under All Output you should see:
Hello, World!
Program ended with exit code: 0
- 启动 XCode
- 在“选择模板”框中,选择 Mac OS X,然后选择命令行工具。按下一步
- 为您的项目命名,选择 C++ 作为类型
- 你应该看到一个带有 main.cpp 的新项目
- 按下运行按钮
在屏幕底部的所有输出下,您应该看到:
你好,世界!
程序以退出代码结束:0