Hi,
I just installed llvm via brew
and added it to my path. I went ahead and tried to compile a simple c++ file using the following command:
clang++ -L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib -g -O3 hello.cpp
Unfortunately, it seems that the error suggests that clang is unable to find the libc++. What could be the issue? Here is a summarized error:
In file included from hello.cpp:1:
In file included from /opt/homebrew/opt/llvm/bin/../include/c++/v1/iostream:43:
In file included from /opt/homebrew/opt/llvm/bin/../include/c++/v1/ios:221:
In file included from /opt/homebrew/opt/llvm/bin/../include/c++/v1/__ios/fpos.h:14:
In file included from /opt/homebrew/opt/llvm/bin/../include/c++/v1/iosfwd:106:
In file included from /opt/homebrew/opt/llvm/bin/../include/c++/v1/__std_mbstate_t.h:14:
/opt/homebrew/opt/llvm/bin/../include/c++/v1/__mbstate_t.h:51:5: error: "We don't know how to get the definition of mbstate_t without <wchar.h> on your platform."
51 | # error "We don't know how to get the definition of mbstate_t without <wchar.h> on your platform."
| ^
.
.
.
/opt/homebrew/opt/llvm/bin/../include/c++/v1/math.h:388:52: error: use of undeclared identifier 'FP_NORMAL'
388 | return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
| ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
The clang++
command is the one shipped with brew’s llvm.