-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OS X 10.9: node-gyp links to libstdc++ instead of libc++ #469
Comments
Apple switched to clang well before. But, yes what switched in 10.9 is that the bundled clang++ version started defaulting to linking to
Correct. This behavior results from this
Would be useful to see the exact errors you are seeing. Generally having Node C++ addons linked to libstdc++ works fine on 10.9 (and of course previous OS X versions). What breaks is when an addon also depends on an external c++ library and that library is linked against libc++ - that condition will lead to odd linking errors when common C++ symbols like
Right, don't do that. Instead the best fix in my opinion is to override Note: Users running node binaries or those who source compile and do not also override this option will end up with node binaries linked against libstdc++. Theoretically having node linked against libstdc++ and an addon linked against libc++ is not a very good idea and could lead to crashes or undefined behavior. In practice however I've not yet seen any problems. That said, if you are targeting >= 10.9 then recommending your users compile their own node that links against libc++ is a good idea. You can do this like: export CXXFLAGS="-mmacosx-version-min=10.9"
export LDFLAGS="-mmacosx-version-min=10.9"
cd node
./configure && make && make install |
Also add fix for when on 10.9 OSX switched to link against libc++ instead of libstdc++ This can cause issues when the module is linked against a different lib than other locally compiled code. See: nodejs/node-gyp#469 (comment)
Needed for unordered_map, see nodejs/node-gyp#469
Node.js 7 onwards specifies linking against |
There's a lot of "noise" on this page - for those who hit this via Google, the solution is simple - update to a newer version of Node. |
In OS X 10.9, Apple switched from gcc to clang which results in a change in the name of the standard library name from libstdc++ (gcc) to libc++ (clang).
However, it seems all modules compiled with node-gyp are linked against libstdc++ on OS X 10.9 . (For example, https://github.com/tbonelaforge/jinac/blob/master/binding.gyp ) Because dynamic libraries that node modules may link against are compiled on 10.9 with clang, there are issues resolving symbols in the standard library.
I realize I can manually set the stdlib to be what it should be with
"OTHER_CFLAGS": ["-stdlib=libc++"]
but this will cause issues on OS X < 10.9.The text was updated successfully, but these errors were encountered: