我的文件被更新爲指向什麼,我認爲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
你好世界看起來如下
#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'中。 – 2012-08-05 16:44:03
在該行中添加$ {PATH}兩次有點奇怪。它不應該導致你的問題,但你也不需要它。 – 2012-08-05 16:45:45
此錯誤消息提示,頭文件無法找到。請記住,標題和編譯器不是同一件事(儘管它們緊密交織在一起)。 – ATaylor 2012-08-05 16:45:48