I’m trying to build Blender on my MacBook M1 running Sequoia 15.2, but get errors like these:
[ 0%] Building CXX object intern/eigen/CMakeFiles/bf_intern_eigen.dir/intern/linear_solver.cc.o
/Users/leon/blender-git/blender/intern/guardedalloc/intern/leak_detector.cc:9:10: fatal error: 'any' file not found
9 | #include <any>
| ^~~~~
/Users/leon/blender-git/blender/source/blender/gpu/glsl_preprocess/glsl_preprocess.cc:9:10: fatal error: 'fstream' file not found
9 | #include <fstream>
| ^~~~~~~~~
In file included from /Users/leon/blender-git/blender/intern/eigen/intern/eigenvalues.cc:13:
In file included from /Users/leon/blender-git/blender/extern/Eigen3/Eigen/Core:19:
/Users/leon/blender-git/blender/extern/Eigen3/Eigen/src/Core/util/Macros.h:679:10: fatal error: 'cmath' file not found
679 | #include <cmath>
| ^~~~~~~
1 error generated.
I cloned the repo, did a make update and a make. I’ve got the latest Xcode Command Line Tools installed, but not Xcode itself. I’ve attached the full build log.
That’s definitely weird. These are standard C++ headers, which are included in the Command Line Tools. The only time I’ve seen similar errors was when upgrading Xcode without completely clearing the CMake cache, which would cause similar issues due to toolchain paths being obsolete.
The first step would be to clear your build directory (which should be ~/blender-git/build_darwin in your case) and try building again. If that doesn’t work, are you aware of anything in your shell environment that could interfere? You could also check if your Command Line Tools do contain the relevant files / aren’t corrupted via something like ls /Library/Developer/CommandLineTools/SDKs/MacOSX15.2.sdk/usr/include/c++/v1, although in practice that seems highly unlikely.
“Just command line tools but not xcode installed” is probably not a very well tested path. Wild guess, did you do xcode-select --install? (not sure if that command is even available with command line tools though)
I’ve deleted the build_darwin directory and tried to rebuild many times. Didn’t help.
The SDK seems properly installed. The SDK files (cmath, fstream, etc.) are all present in /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/c++/v1. And their contents also seems fine.
I created a little CPP demo console application that uses cmath and fstream and get the same “file not found” errors while building, both using a “simple” build and using CMake. There must be something wrong in my environment that causes it to not resolve these files. I will investigate further…
That’s why I’m not simply trying to fix it by installing the full Xcode. I want to get to the bottom of this issue That said, in my reply above I said even a simple CPP file using those libraries won’t build on my system. So maybe it’s just a problem with my particular setup and not Blender.
Of course. But just to be sure I re-ran it. Here is its output: xcode-select: note: Command line tools are already installed. Use "Software Update" in System Settings or the softwareupdate command line interface to install updates
Unintuitively, xcode-select --install installs the Command Line Tools, which is considered the default / basic toolchain on macOS, with Xcode being the extra development kit. As such it’s supposed to be a pretty well tested path, and we also recommend it in our build guide.
Right I see, my guess is that for some external reasons, these paths are being wrongly overridden by something else (perhaps a previous Xcode or Command Line Tools install).
What’s the output of xcrun --show-sdk-path and xcode-select -p? If these values seem wrong, you can switch the active macOS SDK back to the command line tools using xcode-select -s /Library/Developer/CommandLineTools.
And if that still doesn’t resolve the issue, the next troubleshooting step would be to get clang to print out its default include paths, using something like clang -E -x c++ - -v < /dev/null
Yes, it looks like that. I do have some Homebrew packages installed. Maybe those interfere. However, when I start a Terminal and issue at set, the resulting environment variables don’t contain the C_INCLUDE_PATH and CPLUS_INCLUDE_PATH variables.
I already posted the output of xcrun in the screenshot in my post above. I also tried xcode-select -p:
Ah, this seems to be the problem. This is the output I get from running DEVELOPER_DIR=/Library/Developer/CommandLineTools clang -E -x c++ - -v < /dev/null (DEVELOPER_DIR is used to override the active toolchain to the default CLTs since I have multiple ones installed).
#include <...> search starts here:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1
/Library/Developer/CommandLineTools/usr/lib/clang/16/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
/Library/Developer/CommandLineTools/usr/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
End of search list.
This correctly lists /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1. In your case, this path is replaced by a relative path pointing to /Library/Developer/CommandLineTools/usr/include/c++/v1 (which doesn’t even exist).
Why this is the case I don’t know, but this does look like an internal Xcode tool shims / xcrun bug. What you could do is issue a bug report directly to Apple using their Feedback Assistant (which is included by default on macOS). You could also maybe try to uninstall / re-install the CLTs in hopes that they magically fix themselves, but at this point the problem seems to mostly lie internally on the macOS side.
Also for anyone stumbling upon this, a good reference to better understand macOS toolchains and their shim mechanism (which isn’t really intuitive, especially when coming from other *nix systems) is this very good blog post, as well as the man pages for xcode-select and xcrun.
I did some more spelunking, but ultimately couldn’t find a reason for the misconfiguration. I uninstalled the Command Line Tools by deleting the entire /Library/Developer/CommandLineTools folder. I then reinstalled them using xcode-select --install.
Now the search paths look like this:
#include <...> search starts here:
/usr/local/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1
/Library/Developer/CommandLineTools/usr/lib/clang/16/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
/Library/Developer/CommandLineTools/usr/include
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
End of search list.
Blender now builds just fine and those two environment variables are no longer needed. Too bad I didn’t find the root cause for this misconfiguration, but at least my build problem is solved.
Turned out there still was a problem with the Command Line Tools install. I think this issue is totally unrelated to Blender, but maybe it’s worth mentioning here. I noticed Homebrew’s brew doctor command displayed the following error:
Warning: No Cask quarantine support available: unknown reason.
After some searching I found this discussion, which ultimately led me to a solution that worked for me. Again I had to completely delete the /Library/Developer/CommandLineTools folder and reinstall the Command Line Tools manually. So this time I didn’t use xcode-select --install, but manually downloaded and ran the Command Line Tools installer from the Apple Developer website dowloads page.