c++ - 简单的 C++ 代码不起作用

标签 c++ gcc g++

这个非常简单的代码给我带来了很多错误:

#include <iostream>
#include <string>

int main() {
    std::string test = " ";
    std::cout << test;
}

我试图通过在控制台上键入 gcc -o simpletest simpletest.cpp 在 linux 上编译它。我不明白为什么它不起作用。发生了什么事?

最佳答案

尝试使用“g++”而不是“gcc”。

关于c++ - 简单的 C++ 代码不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/267026/

相关文章:

c++ - gfortran undefined reference

opengl - 随处开发 OpenGL 应用程序

C++ 表现出奇怪的行为

c - GCC 交叉编译器(用于 ARM micro)在不存在 FP 指令的函数中提示 'non supported floating point ABI'

android - Mac 非法指令 : 4

c++ - XGboost 上的 mingw' 中未启用外部存储器

c - 如何让 GCC 正常工作?

ubuntu - 如何获取 POSIX strerror_r 而不是 GNU 版本?

c++ - 帮助在 MFC 中使用 CWinThread

c++ - 在 C++ 中,散列字符串值会在 Linux 和 Windows 上产生不同的输出