OpenShadingLanguage: Build issues on macOS Catalina (fatal error: 'wchar.h' file not found)
Problem
Expected behavior:
Actual behavior: CMake works good without warnings, but i couldn’t build it.
I guess this issue is related to this
Versions
- OSL branch/version: https://github.com/imageworks/OpenShadingLanguage/commit/473e1f6e2df1915b54b7f2588e22cd8708824e54
- OS: macOS Catalina beta
- C++ compiler: AppleClang 11.0.0
- LLVM version: 5.0.2
- OIIO version: 2.0.9
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (8 by maintainers)
Solution for macOS Catalina 10.15.3
Use Mac Ports for installing LLVM version 9.0 (
sudo port install llvm-9.0
). We’re going to use theclang
andclang++
compiler that’s included in this package for compiling OSL. Therefore, the command to build OSL from inside its directory will be (we nuke any existing build first):Take a good look at your llvm-9.0 directory if you installed it differently and adjust the paths. Also, I specified
-j16
to use 16 parallel threads for building. If you don’t have a strong machine, change this or leave it out entirely.Attention: If you only use this, then it will end in the error message as described in the issue. The problem is that
wchar.h
that comes with llvm is only a stub that contains the lineThat means that it expects the real
wchar.h
to be accessible which it is not. The correctwchar.h
is provided by the command line tools that you need to install. Since this is also a prerequisite to use Mac Ports, you probably already have done this. If not, check the first part of the installation instructions for Mac Ports which explains the two simple steps.If you have the command line tools, then the folder
/Library/Developer/CommandLineTools
should exist on your machine. In this directory, the different SDKs are available and we’ll use this include path in addition to the include path that LLVM already uses. Therefore, we set the following environment variable forclang++
before building OSLIt is vitally important that you also include LLVM’s normal include path because it should first look there! After that, OSL should build fine.
That’s actually a problem with your Mac. I’ve had the same trouble myself after certain xcode updates. You need to follow these directions:
https://stackoverflow.com/questions/52509602/cant-compile-c-program-on-a-mac-after-upgrade-to-mojave/52530212#52530212
Basically, the solution that worked for me boils down to:
Updating: I ran into this problem on a machine with Catalina, and as said earlier in this thread, the original trick of running macOS_SDK_headers_for_macOS_10.14.pkg that I mentioned above no longer works because 10.15 doesn’t include this pkg.
The diagnosis of the problem and the advice from @halirutan is correct but assumes paths for Macports, so just for the record, for anybody using Homebrew, the simple solution is just to set:
@lgritz I had looked into the SO post you mentioned and tried various things. It’s just not clear to me what happens, but here is a more elaborate report: I looked up the tool-chain with
That indicates to me that headers and libraries should come from the Xcode toolchains available. So I checked for
wchar.h
The viable options seem to be the
XcodeDefault.xctoolchain
and theMacOSX.platform/Developer/SDKs/MacOSX.sdk
but I don’t have any in-depth knowledge of how they are different. Using the latter option and settinggives a whole lot of other errors.
Log File
Using other settings gives other errors. I realize that this is not a problem of OSL because it’s LLVM being incompatible with compiler settings. But information is scarce and every supposed-to-be-solution that’s on the web just feels like people are fumbling around until they get it working. I couldn’t find a reasonable explanation of what really happens, but if someone has further ideas, I’m happy to try them out.