代码之家  ›  专栏  ›  技术社区  ›  user906357

在macOS-Mojave中用gcc编译

  •  2
  • user906357  · 技术社区  · 7 年前

    在升级到Mojave之前,我编译的C程序还不错。我使用了gcc的一个旧版本7.3,我使用找到的指令安装了它 here .

    然后我更新到Mojave,并尝试用gcc main.c编译下面的简单程序:

    #include <stdio.h>
    int main(){
        printf("Hello World\n");
        return 0;}
    

    这将导致以下错误:

    /usr/local/lib/gcc/x86_64-apple-darwin17.5.0/7.3.0/include-fixed/stdio.h:78:10: fatal error: _stdio.h: No such file or directory
     #include <_stdio.h>
          ^~~~~~~~~~
    compilation terminated.
    

    如果我删除include,它将使用printf的隐式声明警告进行编译,但仍将正确编译和运行,打印helloworld。有人知道这个问题吗?我怎么解决?

    1 回复  |  直到 7 年前
        1
  •  3
  •   user906357    7 年前

    /Library/Developer/CommandLineTools/Packages/
    

    然后打开并安装macOS\ uSDK\ uHeaders\ ufor\ uMacOS\ u10.14.pkg。