【问题标题】:g++ compiler: compilation terminated [duplicate]g ++编译器:编译终止[重复]
【发布时间】:2015-08-31 16:55:36
【问题描述】:

我有一个非常简单的程序:

// hello.cpp
#include <iostream>

using namespace std;

int main() {
   cout << "Hello, world!" << endl;
   return 0;
}

当我使用命令提示符 (Windows) 并输入:

g++ -o hello hello.cpp

我收到了这个错误:

In file included from /usr/include/wchar.h:6:0,
                 from /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cwchar:44,

                 from /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/bits/posty pes.h:40,
                 from /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/iosfwd:40,

                 from /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/ios:38,
                 from /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/ostream:38 ,
                 from /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/iostream:3 9,
                 from hello.cpp:2: /usr/include/sys/reent.h:14:20: fatal error: stddef.h: No such file or directory

 #include <stddef.h>
                    ^ compilation terminated.

谁能解决这个问题?我尝试 gcc,一切正常。似乎 g++ 有一些问题。我的 g++ 版本是 4.9.2

【问题讨论】:

  • 我认为这个问题表明 gcc 和 g++ 之间的版本不匹配。你能确认它们是同一个版本吗?
  • 你的 cygwin 安装看起来坏了
  • 我的 gcc 版本是 4.9.3。它们必须在同一个版本中吗?
  • 这可能会有所帮助:stackoverflow.com/questions/19642787/…
  • 谢谢,我会尝试重新安装g++和gcc。

标签: c++ gcc compilation g++ cygwin


【解决方案1】:

我希望你在 Linux 上工作。

尝试安装诸如

之类的 build-essentials
sudo apt-get install build-essential

即使它不起作用,您也可能必须安装 libc6-dev。

【讨论】:

    猜你喜欢
    • 2019-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-12
    • 1970-01-01
    相关资源
    最近更新 更多