带有XCode 2.5的Mac OS X上的gcc命令行 [英] gcc command line on Mac OS X with XCode 2.5

查看:229
本文介绍了带有XCode 2.5的Mac OS X上的gcc命令行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用Mac OS X 10.5.8版本运行MacBook Pro。我下载了XCode版本2.5并安装了它。



此外,我将/XCode2.5/usr/bin添加到我的PATH中。



以下是hello.cc程式:

  #include< iostream> 

int main(void)
{
std :: cout<< 你好,世界<< STD:ENDL;

$ / code>

以下是发生了什么:
$> g ++ hello.cc


hello.cc:在函数'int main()'中:
hello.cc:5:错误:'cout'不是'std'
hello.cc:5:错误:'endl'不是'std'的成员



设置PATH不足以运行gcc实用程序在Mac上的命令行?



谢谢,



查理



  #include< iostream>解决方案


使用namespace std;

int main()
{
cout<< 你好,世界<< ENDL;
返回0;
}


I am currently running a MacBook Pro with Mac OS X Version 10.5.8. I downloaded XCode version 2.5 and installed it.

Further, I added /XCode2.5/usr/bin to my PATH.

Here is hello.cc program:

#include <iostream>

int main(void)
{
  std::cout << "hello, world" << std:endl;
}

Here is what happens: $> g++ hello.cc

hello.cc: In function ‘int main()’: hello.cc:5: error: ‘cout’ is not a member of ‘std’ hello.cc:5: error: ‘endl’ is not a member of ‘std’

Is setting the PATH not sufficient to run the gcc utilities from the command line on a Mac?

Thanks,

Charlie

解决方案

This works:

#include <iostream>
using namespace std;

int main()
{
  cout << "hello, world" << endl;
  return 0;
}

这篇关于带有XCode 2.5的Mac OS X上的gcc命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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