stdlib.h file not found and macOS SDK package installer also not found
I have macOS High Sierra 10.13.6 (For various reason I will not update) and Xcode 10.1 installed alongside command-line-tools.
I am trying to compile a certain software that is attempting to open the following header file:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/stdlib.h
but it cannot find the file. When I manually explore the folder, the stdlib.h
file is located at:
Developer/CommandLineTools/sr/include/c++/v1/stdlib.h
I have tried so many things, from uninstalling and reinstalling, to trying out older versions, etc. I tried to "manually" install it, but there is no macOS SDK package to install.
On any system with gcc, you can find out the location of system include files with the command gcc -v -xc++ /dev/null -fsyntax-only
. This gives you all the paths for #include
. (gcc is included into xcode)
If you will not find out the path /usr/local/include
in the list, then you need to correct it with the command sudo xcode-select --switch /Library/Developer/CommandLineTools
. This will not modify the behaviour of applications developed/run in Xcode. (this path can be or is already part of your bash profile file).
Apple has an installer for C++ libraries you can install.
xcode-select --install
If you have Xcode installed (or don't mind downloading it from the App Store) run it to validate all the command line tools are installed as well as additional tools. Lastly, once these are installed, check for normal software updates to ensure the command line updates are applied.
You might need to look at the output of the build script to see if you just need to reset the default location of the compile tools:
xcode-select --reset