【问题标题】:installed MinCW & cygwin but can't compile anything安装了 MinCW & cygwin 但无法编译任何东西
【发布时间】:2014-05-21 20:31:28
【问题描述】:

每次我尝试编译一个简单的 hello world 程序时,我都会得到一个充满错误的控制台。我有 DevC++,当我使用 IDE 时,它编译得很好并且工作得很好,但我开始从 Notepad++ 和命令行做所有事情。这是我的错误:

C:\Users\root\Desktop>g++ helloworld.c -o helloworld.exe
In file included from c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/
4.4.3/../../../../include/stdio.h:26,
                from helloworld.c:1:
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../i686
-w64-mingw32/include/stddef.h:20: error: expected constructor, destruc
tor, or type conversion before '_set_errno'
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../i686
-w64-mingw32/include/stddef.h:21: error: expected constructor, destruc
tor, or type conversion before '_get_errno'
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../i686
-w64-mingw32/include/stddef.h:26: error: expected initializer before '
__threadhandle'
In file included from helloworld.c:1:
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:191: error: 'size_t' has not been declared
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:202: error: 'size_t' has not been declared
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:206: error: 'size_t' has not been declared
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:209: error: 'size_t' has not been declared
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:210: error: 'size_t' has not been declared
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:289: error: expected constructor, destructor, or type conv
ersion before 'fread'
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:290: error: expected constructor, destructor, or type conv
ersion before 'fwrite'
In file included from helloworld.c:1:
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:438: error: 'size_t' has not been declared
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:442: error: 'size_t' has not been declared
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:446: error: expected constructor, destructor, or type conv
ersion before 'fgetwc'
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:447: error: expected constructor, destructor, or type conv
ersion before 'fputwc'
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:448: error: expected constructor, destructor, or type conv
ersion before 'ungetwc'
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:453: error: expected constructor, destructor, or type conv
ersion before 'getwc'
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:454: error: expected constructor, destructor, or type conv
ersion before 'getwchar'
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:456: error: expected constructor, destructor, or type conv
ersion before 'putwc'
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:458: error: expected constructor, destructor, or type conv
ersion before 'putwchar'
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:472: error: 'size_t' has not been declared
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:474: error: 'size_t' has not been declared
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:496: error: expected constructor, destructor, or type conv
ersion before '_fgetwchar'
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:497: error: expected constructor, destructor, or type conv
ersion before '_fputwchar'
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:502: error: expected constructor, destructor, or type conv
ersion before 'fgetwchar'
c:\strawberry\c\bin\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../incl
ude/stdio.h:503: error: expected constructor, destructor, or type conv
ersion before 'fputwchar'

【问题讨论】:

  • 看起来好像 stddef.h 没有正确解析。 size_t 是未知的,从而导致各种后续错误。也许DEVC ++设置了一个影响gcc的环境变量?参照。 gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html,或者相反,mingw 的 gcc 必须缺少一个。
  • 谢谢,我让它工作了,我卸载了 devC++,然后重新安装了 mincw devc++ 一定与某些东西冲突

标签: c compilation mingw


【解决方案1】:

看起来好像您使用了错误的库(可能文件已损坏或在编译器搜索的位置不存在)。或者,您可能还没有添加所有需要的库。当我输入错误的库名称时,我遇到了同样的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-06-29
    • 2022-12-16
    • 2018-09-20
    • 1970-01-01
    • 2019-02-28
    • 2020-07-31
    • 2021-05-02
    • 2012-09-06
    相关资源
    最近更新 更多