【发布时间】:2012-08-02 19:52:52
【问题描述】:
我的个人资料已更新以指向我认为正确的位置:
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 << "Hello World!";
return 0;
}
无法从命令行和 TextMate 执行
[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
我的路上还有什么遗漏的?
【问题讨论】:
-
你在xcode里面安装了命令行工具包吗?那应该把你需要的东西放在
/usr/bin/,而不是Xcode.app -
在该行中添加两次 ${PATH} 有点奇怪。它不应该引起你的问题,但你也不需要它。
-
此错误消息提示,找不到头文件。请记住,头文件和编译器不是一回事(尽管它们紧密相连)。
-
我在
/usr/bin中没有任何内容(gcc/g++ 相关),这是我怀疑的问题,但我确实将Xcode.app升级到了最新版本,我假设其中包括命令行开发工具.我该如何确认?如何强制安装命令行工具? -
似乎在 Xcode 4.3 中,命令行工具位于
/Applications/Xcode.app/Contents/Developer/usr/bin/中,由 stackoverflow.com/questions/10346369/… 回答
标签: c++ osx-mountain-lion