I have this node extension made by a colleague and I'm trying to compile it through node-gyp configure (everything alright) and then node-gyp build (fatal error, 'thread' file not found). Now, I believe this is a problem of gcc, and I read somewhere that I need as flag -stdlib=libc+++. My binding.gyp file looks like this:
{
"targets": [
{
"target_name": "overcpu",
"sources": [ "overcpu.cpp" ],
"cflags" : [ "-stdlib=libc++" ]
}
]
}
But I still get the error. I installed XCode and the developer tools, moreover not satisfied I installed gcc through brew. Unfortunately I keep receiving the same error.
By doing gcc -v I get the following output:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.3.0
Thread model: posix
Is there something wrong with my gcc, or is it node-gyp (v1.0.1) which is driving me crazy?
Thanks a lot!
You need to also add -std=c++11 to your cflags argument list in order to fully activate C++11 support.
UPDATE: For OSX specifically (the cflags should work on BSD and Linux), you will need to also add a condition inside your targets settings like so:
{
"targets": [
{
"target_name": "overcpu",
"sources": [ "overcpu.cpp" ],
"cflags" : [ "-std=c++1", "-stdlib=libc++" ]
"conditions": [
[ 'OS!="win"', {
"cflags+": [ "-std=c++11" ],
"cflags_c+": [ "-std=c++11" ],
"cflags_cc+": [ "-std=c++11" ],
}],
[ 'OS=="mac"', {
"xcode_settings": {
"OTHER_CPLUSPLUSFLAGS" : [ "-std=c++11", "-stdlib=libc++" ],
"OTHER_LDFLAGS": [ "-stdlib=libc++" ],
"MACOSX_DEPLOYMENT_TARGET": "10.7"
},
}],
],
}
]
}