ThirdPinion
11Jun/142

Node-Gyp on OSX

If you have Xcode installed on your Apple laptop, then you should have gotten a C++ compiler in the form of CLang.  You'd think this would work fine with Node-Gyp...and it does.  With a tweak.

Add something like this to the "targets" section of the binding.gyp file:


"xcode_settings": {
"GCC_ENABLE_CPP_RTTI": "YES",
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
"OTHER_CPLUSPLUSFLAGS":["-stdlib=libc++"],
"OTHER_LDFLAGS":["-stdlib=libc++"],
"CLANG_CXX_LANGUAGE_STANDARD":"c++11",
"MACOSX_DEPLOYMENT_TARGET":"10.7"
}

Otherwise you'll probably get a litany of errors like

"cannot use typeid with -fno-rtti"

and

"cannot use 'throw' with exceptions disabled"

Comments (2) Trackbacks (0)
  1. Can you do potentially drop CLang altogether and just use gcc and friends? something like,

    CC=gcc
    CPP=g++

    • The problem is Apple (and FreeBSD) dropped support for gcc and g++ in favor of Clang. You can probably get around it with Homebrew, but it doesn’t seem to be recommended by Apple or the community at large.


Leave a comment

No trackbacks yet.