3

It seems like my gcc is broken.

When I try to install package from PyPI I have this error:

    ./uwsgi.h:165:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^~~~~~~~~
1 error generated.
In file included from core/protocol.c:1:
./uwsgi.h:165:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^~~~~~~~~
1 error generated.

XCode command line tools are installed:

    ➜  xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

And gcc from brew installed:

➜  brew install gcc
Warning: gcc 8.2.0 is already installed and up-to-date
To reinstall 8.2.0, run `brew reinstall gcc`

When I try to recognize which gcc is used I have /usr/bin/gcc. I think it's XCode version.

But there is no gcc binary in brew:

➜  ls /usr/local/bin/gcc-*
/usr/local/bin/gcc-8        /usr/local/bin/gcc-ar-8     /usr/local/bin/gcc-nm-8     /usr/local/bin/gcc-ranlib-8

What can I do in this situation? How can I fix gcc?

andre487
  • 1,261
  • 2
  • 18
  • 27
  • It's there... use `/usr/local/bin/gcc-8` – Mark Setchell Oct 28 '18 at 16:58
  • Yes, but why I don't have stdio.h? – andre487 Oct 28 '18 at 17:46
  • Try firing up `Xcode` at least one time and getting it to check for updates, and also go to `AppStore` and check for updates there. There is also some funky new `Software Update` thing if you click `Apple Menu`->`System Preferences`->`Software Update`. Visit them all one time. – Mark Setchell Oct 28 '18 at 19:12
  • 1
    Same problem here: gcc (clang) works, but gcc-8 (gnu) gives this error "/usr/local/Cellar/gcc/8.2.0/lib/gcc/8/gcc/x86_64-apple-darwin17.7.0/8.2.0/include-fixed/stdio.h:78:10: fatal error: _stdio.h: No such file or directory" – Vesal Nov 05 '18 at 20:38
  • Sorry, my problem may be different... there are issues with both compilers: https://stackoverflow.com/questions/52509602/cant-compile-c-program-on-a-mac-after-upgrade-to-mojave (clang) and https://stackoverflow.com/questions/52974321/compiling-with-gcc-in-macos-mojave (gnu) – Vesal Nov 05 '18 at 20:55
  • Possible duplicate of [Can't compile C program on a Mac after upgrade to Mojave](https://stackoverflow.com/questions/52509602/cant-compile-c-program-on-a-mac-after-upgrade-to-mojave) – Cris Luengo Jun 04 '19 at 04:46

3 Answers3

6

The correct answer was in this thread: https://stackoverflow.com/a/52530212/1377912

The new Xcode doesn't provide headers by default. You should install it manually:

open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
pkamb
  • 33,281
  • 23
  • 160
  • 191
andre487
  • 1,261
  • 2
  • 18
  • 27
1

As I wrote this answer, Mojave is deprecated and now is the age of Big Sur! but this problem still exists!

I don't know that following command will work on Mojave or not, but is working on Big Sur! if you still have this problem, just simply examine that.

Just set CFLAGS(for C compilers) or CXXFLAGS (for C++ compilers ) something like this:

export CFLAGS="-isysroot $(xcrun --sdk macosx --show-sdk-path) -I/usr/include -L/usr/lib -I$(xcrun --sdk macosx --show-sdk-path)/usr/include"

or

export CXXFLAGS="-isysroot $(xcrun --sdk macosx --show-sdk-path) -I/usr/include -L/usr/lib -I$(xcrun --sdk macosx --show-sdk-path)/usr/include"

It probably removes your fatal error: 'stdio.h' file not found error. If this error been removed, it might that you face to new problems, don't count them as this problem and loose your success by manipulating this! In this situation just be care about your new problems and try to fix them, one by one!

I hope this answer be useful for you

AbdolHosein
  • 528
  • 4
  • 15
0

Maybe it's a stupid answer but have you tried to create and compile a very simple c file? However in my mojave system i've tried the gcc -v command and i have this output:

Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include- 
dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
Apple LLVM version 10.0.0 (clang-1000.10.44.2)
Target: x86_64-apple-darwin18.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
  • This one was compiled successfully: https://pastebin.com/FZbzdncm And this too: https://pastebin.com/TQs852fJ But why I don't have stdio.h when compile uWSGI? – andre487 Oct 28 '18 at 17:50