GCC fatal error: stdio.h: No such file or directory

前端 未结 5 1605
清酒与你
清酒与你 2020-11-28 22:15

I\'m trying to compile a program in C on OS X 10.9 with GCC 4.9 (experimental). For some reason, I\'m getting the following error at compile time:

gcc: fatal         


        
相关标签:
5条回答
  • 2020-11-28 22:28

    ubuntu users:

    sudo apt-get install libc6-dev

    specially ruby developers that have problem installing gem install json -v '1.8.2' on their VMs

    0 讨论(0)
  • 2020-11-28 22:36

    Mac OS X

    I had this problem too (encountered through Macports compilers). Previous versions of Xcode would let you install command line tools through xcode/Preferences, but xcode5 doesn't give a command line tools option in the GUI, that so I assumed it was automatically included now. Try running this command:

    xcode-select --install
    

    Ubuntu

    (as per this answer)

    sudo apt-get install libc6-dev
    

    Alpine Linux

    (as per this comment)

    apk add libc-dev
    
    0 讨论(0)
  • 2020-11-28 22:39

    I know my case is rare, but I'll still add it here for someone who troubleshoots it later. I had a Linux Kernel module target in my Makefile and I tried to compile my user space program together with the kernel module that doesn't have stdio. Making it a separate target solved the problem.

    0 讨论(0)
  • 2020-11-28 22:43

    Mac OS Mojave

    The accepted answer no longer works. When running the command xcode-select --install it tells you to use "Software Update" to install updates.

    In this link is the updated method:

    Open a Terminal and then:

    cd /Library/Developer/CommandLineTools/Packages/
    open macOS_SDK_headers_for_macOS_10.14.pkg
    

    This will open an installation Wizard.

    Update 12/2019

    After updating to Mojave 10.15.1 it seems that using xcode-select --install works as intended.

    0 讨论(0)
  • 2020-11-28 22:52

    I had the same problem. I installed "XCode: development tools" from the app store and it fixed the problem for me.

    I think this link will help: https://itunes.apple.com/us/app/xcode/id497799835?mt=12&ls=1

    Credit to Yann Ramin for his advice. I think there is a better solution with links, but this was easy and fast.

    Good luck!

    0 讨论(0)
提交回复
热议问题