使用 G++ 编译C++程序时出错
Error while compiling a C++ program with G++
v 这是main.cpp
:
#include <stdio.h>
using namespace std;
int main() {
cout << "Hello, World!" << endl;
return 0;
}
为了编译它,我进入 cmd 并键入 g++ main.cpp
但它给了我 2 个错误,说cout
和endl
都没有声明。我只能想象这是因为它找不到命名空间std
或无法包含<stdio.h>
.我将如何做到这一点?
您必须包含iostream
,而不是stdio.h
才能使用std::cout
和std::endl
。
相关文章:
- 重载操作程序时出错>>用于类中的字符串 memebr
- 分段错误当我试图运行程序时出错
- 使用 Visual Studio 2019 构建 Hello World wxwidgets 应用程序时出错
- 在另一台 PC 上执行程序时加载 SDL2 共享库时出错
- 在发布模式下启动使用库的静态链接编译的应用程序时出错
- 从 ParaView 构建自定义 Qt 应用程序示例时出错
- 程序_free_dbg(块,_UNKNOWN_block)出错
- 在调试模式下,所有程序都运行良好,但在发布模式下,我在cudaMalloc操作中出错
- 在OpenGL中使用程序集代码渲染视频时出错
- 程序的 substr() 函数中的输出出错
- 编译特征程序时出错:错误:'seq'不是'Eigen'的成员
- 将 Dr. Memory 与 Visual Studio 项目配合使用时出错:缺少应用程序所需的库
- 在返回另一个函数的函数中执行程序期间出错
- 在 MacOSX 上编译 OpenGL 程序时出错('ld:找不到 -lopengl32 的库)
- 在比较特定输入中的程序的数组中出错
- 编译 libraw 程序时出错
- 尝试使用共享库部署QT应用程序时出错
- 编译 CPP 应用程序时出错。 "error: 'posix_memalign' was not declared in this scope"
- 第二次构建C++程序时出错
- 使用CUDA编译OpenCV示例程序时出错