Created
October 18, 2019 10:33
-
-
Save cuiwm/5cc66fa1b9f0195eeb9451f233c610b7 to your computer and use it in GitHub Desktop.
fix:fatal error: 'stdlib.h' file not found
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "diagnose tool for problem: \"fatal error: 'stdlib.h' file not found\"" | |
echo "by AndrewChoe(xgod@163.com)" | |
# reason: | |
# System header dir /usr/include has gone forever. | |
# However, some software may fail to build correctly against the SDK and require macOS headers to be installed in the base system under /usr/include | |
cat >/tmp/hello.c <<-"EOF" | |
#include <stdlib.h> | |
int main() { | |
//ident with space Not Tab | |
exit(0); | |
} | |
EOF | |
clang /tmp/hello.c | |
if [ $? -ne 0 ] ; then | |
echo "oops, clang not work" | |
else | |
echo "clang environment is good. bye" | |
exit 0 | |
fi | |
echo "--------------find all clang(include symbol link)------------" | |
sudo find /usr -name "clang" | |
echo "" | |
echo "" | |
echo "--------------find all clang real file (NOT sysmbol)---------" | |
sudo find /usr -name "clang" -type f | |
echo "" | |
echo "" | |
echo "--------------clang location:--------------" | |
command -v clang | |
echo "" | |
echo "" | |
echo "--------------clang search dirs--------------" | |
clang -print-search-dirs | |
echo "" | |
echo "" | |
echo "--------------clang symbol link:--------------" | |
readlink `command -v clang` | |
# for macOS 10.14 | |
#open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg | |
TIMELIMIT=10 | |
# 4 seconds | |
echo "press key y with enter, will execute command: xcode-select --install" | |
read -t $TIMELIMIT variable <&1 # ^^^ # In this instance, "<&1" is needed for Bash 1.x and 2.x, # but unnecessary for Bash 3.x. | |
if [ -z "$variable" ] # Is null? | |
then echo "you press nothing" | |
exit 0 | |
else | |
#echo "variable = $variable" | |
if [ "$variable" == "y" ] ; then | |
xcode-select --install | |
else | |
echo "you press $variable" | |
fi | |
fi | |
# brew doctor | |
# catalina work around | |
# brew unlink llvm@4 | |
#Unlinking /usr/local/Cellar/llvm@4/4.0.1_1... 341 symlinks removed | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment