Node-gyp无法编译nodejs扩展名('fatal error,thread'file not found) [英] Node-gyp cannot compile a nodejs extension ('fatal error, thread' file not found)
问题描述
我有一个同事创建了这个节点扩展,我试图通过 node-gyp configure
(一切正常)进行编译,然后 node-gyp build
(致命错误,找不到线程文件
)。现在,我认为这是一个gcc的问题,我读了一些我需要的地方,如 -stdlib = libc +++
。我的 binding.gyp
文件如下所示:
{
targets:[
{
target_name:overcpu,
sources:[overcpu.cpp],
cflags:[ - stdlib = libc ++]
}
]
}
但我仍然得到错误。我安装了XCode和开发者工具,而且还不满意,我安装了 gcc
到 brew
。不幸的是,我不断收到相同的错误。
通过执行 gcc -v
我得到以下输出:
配置为:--prefix = / Applications / Xcode.app /目录/ Developer / usr --with-gxx-include-dir = / usr / include / c ++ / 4.2.1
Apple LLVM version 5.1 clang-503.0.40)(基于LLVM 3.4svn)
目标:x86_64-apple-darwin13.3.0
线程模型:posix
我的 更新:对于OSX来说( I have this node extension made by a colleague and I'm trying to compile it through But I still get the error. I installed XCode and the developer tools, moreover not satisfied I installed Is there something wrong with my Thanks a lot! You need to also add UPDATE: For OSX specifically (the
这篇关于Node-gyp无法编译nodejs扩展名('fatal error,thread'file not found)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! gcc
有问题,还是 node-gyp $ c
cflags
参数添加 -std = c ++ 11
列表,以便完全激活C ++ 11支持。
$ b cflags code>应该在BSD和Linux上工作),您还需要在
目标
设置中添加一个条件,如下所示:
{
targets:[
{
target_nam e: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
},
}],
],
}
]
}
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++" ]
}
]
}
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
gcc
, or is it node-gyp
(v1.0.1) which is driving me crazy?-std=c++11
to your cflags
argument list in order to fully activate C++11 support.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"
},
}],
],
}
]
}