3

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.

  • You post is not on-topic here, but if you want help on StackOverflow, please remember to include your build settings - specifically your the paths for your include folders (essentially the -I parameters). This "special software" seems to be vastly different from standard software - normally when you create a project in Xcode, or almost anything else, you'll be able to include stdlib.h without any further. – jksoegaard Jul 8 at 19:26
  • Command line tools are on topic here, but this might need to be migrated to stack overflow if it's about the build tools or OP can't refine the question so that a basic setup answer doesn't apply. – bmike Jul 8 at 20:25
  • Oh, I'm sorry. It's my first time using this website. And yes you are correct, if I include stdlib.h in a project in xcode it is able to run. The 'special software' is trying to find it in a unique location. – macosx136 Jul 8 at 22:14
2

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
  • I have tried both before and it does not solve the issue. When I try to run a project in xcode and include stdlibs, it works fine though. Very bizarre – macosx136 Jul 8 at 22:12
  • @macosx136 Bummer - is there a reason not to share what the "certain software" is or summarize the build script and output? You could post a gist on GitHub and take it down once people had a look if you're worried about documenting the details here. – bmike Jul 8 at 23:42
2

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).

You must log in to answer this question.

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