如何在XCode 4中运行C ++程序? [英] How do I run a C++ program in XCode 4?

查看:110
本文介绍了如何在XCode 4中运行C ++程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的Mac上的XCode中编写一个C ++程序。我写了这个基本的测试它。当我建立,我得到一个Build Successful消息。

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.

但是,我不能运行它!如果我命中Command + R什么也没有发生。当我去项目 - >运行运行选项被禁用。

However, I cannot run it! If I hit Command+R nothing happens. When I go to Project->Run the Run option is disabled.

#include <iostream>

using namespace std;

int main()
{

    cout << "helo" << endl;

}


推荐答案


  1. 启动XCode


  2. 在选择模板框中,选择Mac OS X,然后选择命令行工具。按下


  3. 将您的项目名称,请选择C ++作为类型


  4. 您应该会看到一个包含main.cpp的新项目


  5. 按下运行按钮

  6. 在屏幕底部,在所有输出下,您应该会看到:

  1. Launch XCode
  2. In the "Choose template" box, pick Mac OS X, then Command Line Tool. Press Next
  3. Give your project a name, select C++ as the type
  4. You should see a new project with main.cpp
  5. press the Run button
  6. At the bottom of the screen, under All Output you should see:

Hello,World!

程序以退出代码结束:0

Hello, World!
Program ended with exit code: 0

这篇关于如何在XCode 4中运行C ++程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆