C ++ Hello World麻烦OSX10.8 [英] C++ Hello World trouble on OSX10.8

查看:133
本文介绍了C ++ Hello World麻烦OSX10.8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的个人资料已更新,指向我认为正确的位置:

  PATH = $ {PATH}:/ Applications / Xcode.app / Contents / Developer / usr / bin:$ {PATH} 

找到编译器

  [11:39:32]〜:$ which g ++ 
/Applications/Xcode.app/Contents/Developer / usr / bin // g ++
[11:39:35]〜:$ which gcc
/Applications/Xcode.app/Contents/Developer/usr/bin//gcc

Hello world如下所示

  #include< iostream> 
using namespace std;

int main()
{
cout< 你好,世界!;
return 0;
}

无法从命令行和TextMate执行

  [11:40:15]桌面:$ g ++ untitled.cpp 
untitled.cpp:1:20:error:iostream:文件或目录
untitled.cpp:在函数'int main()'中:
untitled.cpp:6:错误:'cout'未在此范围内声明



在我的路径中还有其他什么,我失踪了吗?



安装Xcode命令行工具



>



检查您的 / usr / bin ,并找到:





再试一次..一切正常工作



从侧面来看,从OSX10.7升级到OSX10.8很奇怪,删除了这些链接


My profile is updated to point to what i think is the right location:

  PATH=${PATH}:/Applications/Xcode.app/Contents/Developer/usr/bin:${PATH}

Compilers are found

[11:39:32] ~: $ which g++
/Applications/Xcode.app/Contents/Developer/usr/bin//g++
[11:39:35] ~: $ which gcc
/Applications/Xcode.app/Contents/Developer/usr/bin//gcc

Hello world looks as follows

#include <iostream>
using namespace std;

int main ()
{
  cout << "Hello World!";
  return 0;
}

Fails to execute both from command line and TextMate with

[11:40:15] Desktop: $ g++ untitled.cpp 
untitled.cpp:1:20: error: iostream: No such file or directory
untitled.cpp: In function ‘int main()’:
untitled.cpp:6: error: ‘cout’ was not declared in this scope

What else should i have in my path and am missing please?

解决方案

The answer is, as always, obvious

Install Xcode Command Line Tools

Check your /usr/bin and find there:

Try again .. Everything works automagically

On a side note, it is odd that upgrade from OSX10.7 to OSX10.8 removed these links

这篇关于C ++ Hello World麻烦OSX10.8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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