I'm trying to get emscripten to work on OS X 10.8, see this post for some related issues there. Apparently the clang++
version shipped with Xcode is too old, so I got a recent clang 3.7.0 using MacPorts. I even told CMake to use that compiler (passing -DCMAKE_CXX_COMPILER=clang++-mp-3.7
on the command line), but it still fails:
[ 33%] Building CXX object CMakeFiles/optimizer.dir/parser.cpp.o
/opt/local/bin/clang++-mp-3.7 -std=c++11 -fno-exceptions -fno-rtti -O3 -DNDEBUG
-o CMakeFiles/optimizer.dir/parser.cpp.o
-c …/emsdk/emscripten/master/tools/optimizer/parser.cpp
In file included from …/emsdk/emscripten/master/tools/optimizer/parser.cpp:2:
In file included from …/emsdk/emscripten/master/tools/optimizer/parser.h:12:
…/emsdk/emscripten/master/tools/optimizer/istring.h:3:10: fatal error:
'unordered_set' file not found
#include <unordered_set>
^
1 error generated.
I can reproduce that issue by launching the compiler from the command line. In parallel build mode, sometimes it's instead complaining about <cstdint>
for optimizer.cpp
instead. Both these headers exist in /opt/local/libexec/llvm-3.7/include/c++/v1/
.
- What's the canonical way to use the macports-installed version of
clang++
including its headers? Do I have to use-I
and work out the full path, or is there something shorter? - Can I safely do so without also switching the runtime library to the one shipped with MacPorts' clang? If not, can I somehow encode the full path of the runtime library into the created binary, either for that single library or using the
-rpath
argument told
or some equivalent alternative?
Update: I get unresolved symbols when I try to link stuff after specifying the include directory manually, and I don't know how to solve that. Thelibcxx
package from MacPorts is empty except for a readme file.
I've solved the original problem by adding
CXXFLAGS=--stdlib=libc++
to the environment. Then even the system version of clang will do everything I need. That flag works magic for MacPorts' version ofclang
as well: specifying that I get a successful build, and I can even verify (using the-E
compiler switch) that it's using the headers I mentioned before. I'm still not certain whether there is anything to ensure that the headers match the system's version oflibc++
, though.