简体   繁体   English

C代码无法在mac Terminal中编译。

[英]C code won't compile in mac Terminal.

Whenever I run $ /developer/usr/bin/gcc -v main.c -o main in Terminal, I get the following error: stdio.h: No such file or directory. 每当我在终端中运行$ / developer / usr / bin / gcc -v main.c -o main时,都会出现以下错误:stdio.h:没有这样的文件或目录。

Here is the main.c file 这是main.c文件

#include <stdio.h>

int main(void){
    int i;
    for(i = 0; i<10;i++){
        puts("Hello World!\n");
    }
    return 0;
}

I am pretty good with C, however I usually use xcode to compile any C command line programs. 我对C相当满意,但是我通常使用xcode编译任何C命令行程序。 The same code runs fine in Xcode, what am I doing wrong? 相同的代码在Xcode中运行良好,我在做什么错呢?

I had the same problem and fixed it. 我有同样的问题,并已解决。 Just install xCode's command line tools and it'll all work just fine! 只需安装xCode的命令行工具,它就可以正常工作!

Hope it helps! 希望能帮助到你! :) :)

You can install xcode tools with the command - 您可以使用以下命令安装xcode工具-

xcode-select --install

A fresh install of xcode command line tools will require 130MB of space and does require sudo access. 全新安装的xcode命令行工具将需要130MB的空间,并且确实需要sudo访问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM