macOS Big Sur 11.1 can't find stdlib.h w

Viewed 1462

I am in my build folder of my cpp project and want to compile make and as a response i get

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/stdlib.h:97:15: fatal error: 'stdlib.h' file not
      found
#include_next <stdlib.h>

also I can't compile in Clion either.

I tried to set differnt paths with xcode-select -p and the sdk packages isn't avaible anymore.

1 Answers

If you recently updated to Big Sur, you will need to re-run xcode-select --install to re-install the XCode Command Line Tools (also available via https://developer.apple.com/download/more/).

If you end up with a library path issue, the following may help:

_sdk_root=`xcrun --sdk macosx --show-sdk-path`
export LIBRARY_PATH="${_sdk_root}/usr/lib"

This sets the LIBRARY_PATH to the appropriate system /usr/lib XCode would use.

Similarly, adding -I${_sdk_root}/usr/include (you'll still need the above _sdk_root= line) may help your compiler find the appropriate header.

Related