6

When I compile a package, I got the following error:

$ make
clang -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2  -I/usr/local/include/scws  -I. -I./ -I/usr/local/Cellar/postgresql/11.3/include/server -I/usr/local/Cellar/postgresql/11.3/include/internal -I/usr/local/Cellar/icu4c/64.2/include -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/libxml2   -c -o zhparser.o zhparser.c
clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk' [-Wmissing-sysroot]
In file included from zhparser.c:10:
In file included from /usr/local/Cellar/postgresql/11.3/include/server/postgres.h:46:
/usr/local/Cellar/postgresql/11.3/include/server/c.h:59:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^~~~~~~~~
1 error generated.

When I search this error online, all the online problems are not having header files at /usr/include/. But when I check the directory, it has many header files

$ ls -l /usr/include/stdio.h
-r--r--r--  1 root  wheel  16319 Jan 22  2018 /usr/include/stdio.h

$ ls -l /usr/include/ | wc -l
     266

So, what can I do in my case?

Thanks a lot.

Edited: I updated the error output. I just found out it had a warning too: clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk', But I have MacOSX10.13.sdk instead because I am running MacOSX10.13. I have no ideas why it's looking for 10.14 sdk and not sure if this is the root cause or not.

14
  • 1
    What version of Xcode and gcc? clang does not look in /usr/include now developer.apple.com/documentation/xcode_release_notes/…
    – mmmmmm
    Jun 14, 2019 at 11:04
  • @Mark thanks for the reply. My Xcode version is Version 9.4.1 (9F2000), xcode-select version 2349, Apple LLVM version 9.1.0 (clang-902.0.39.2). I can not update XCode now due to weird apple app store problem. I am in China now. and iphone and MacOS has many weird things here. I don't want to talk about the upgrade issue now. For my current setup, how can I fix this issue? Thank you very much.
    – sgon00
    Jun 14, 2019 at 11:11
  • @Mark btw, I read that link. I don't have the path /Library/Developer/CommandLineTools/Packages/. Only Library/, SDKs/, usr/ are inside CommandLineTools/.
    – sgon00
    Jun 14, 2019 at 11:13
  • Yep well you have a different Xcode so not the same. I would however reinstall the command line tool;s and run xcode-select
    – mmmmmm
    Jun 14, 2019 at 11:16
  • 1
    Looks like you need to reinstall xcode
    – mmmmmm
    Jun 14, 2019 at 11:57

1 Answer 1

5

The root cause of the error message is from the warning message:

clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk'

By checking SDKs directory:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
$ ls
MacOSX.sdk/      MacOSX10.13.sdk

So, to workaround the problem, it's either re-install xcode suggested by @Mark or create a symbolic link like the following:

$ sudo ln -s MacOSX.sdk/ MacOSX10.14.sdk

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .