C++ Hello World not compiling
C++ Hello World not compiling
我最近刚安装了OSX lion并安装了xcode 4。
我在某个目录下创建了一个文件,并将以下代码放入其中:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!";
return 0;
}
然后我运行gcc filename.cc
我得到这些错误:
1。cc:3:20: error: iostream: No such file or directory1.在函数' int main() '中:1.Cc:8: error: ' cout '未在此范围内声明
怎么了?
编辑:如果我运行g++ filename。我得到相同的错误。
1。cc:3:20: error: iostream: No such file or directory1.在函数' int main() '中:1.Cc:8: error: ' cout '未在此范围内声明
为什么使用gcc?
看起来您的包含路径没有设置,所以没有找到iostream。这些通常是自动设置的—您需要像INCLUDE=
这样的环境变量或者您可以在命令行中设置这些,如
g++ -i filename.cc
试试这个:
g++ filename.cc
你也可以尝试使用clang++
,它将使用苹果的新编译器:
clang++ filename.cc
相关文章:
- OpenMP卸载说'fatal error: could not find accel/nvptx-none/mkoffload'
- 使用JsonCpp将数据返回到带有pybind11的python会在python调用中产生Symbol not foun
- OpenCV Android C++ imwrite not found
- 应用程序崩溃并显示"symbol _ZdlPvm, version Qt_5 not defined in file libQt5Core.so.5 with link time reference"
- 使用单词"not"作为C ++类的名称会导致VS2019错误
- 错误"Could not find Boost"(缺少:上下文标头)
- 如何修复"error: ‘_1’ was not declared in this scope"?
- 套接字连接"Operation not permitted"错误,甚至使用升压/平发器根.cpp
- Is !NaN not a NaN?
- 为什么我会" void value not ignored as it ought to be"?
- 解决"ld: library not found for -ltensorflow_framework.2.3.0"
- 加载与引用 .NET DLL 位于同一文件夹中的引用的 .NET DLL 时"Not found"异常
- Directx 11 - CompileFromFile() is not compiling
- 方法错误"not all control paths return a value"和方法不返回值
- Centos7 g++ "to_string is not in a member of std"
- QtConcurrent::mapped not compiling
- boost multi_index_container not compiling
- Ubuntu OpenCV not compiling
- Microsoft Visual C++ Not Compiling
- C++ Hello World not compiling