Node-gyp无法编译nodejs扩展名('fatal error,thread'file not found) [英] Node-gyp cannot compile a nodejs extension ('fatal error, thread' file not found)

查看:332
本文介绍了Node-gyp无法编译nodejs扩展名('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

我的 gcc 有问题,还是 node-gyp


解决方案:$ c>(v1.0.1)这让我疯狂?

您还需要为 cflags 参数添加 -std = c ++ 11 列表,以便完全激活C ++ 11支持。


$ b

更新:对于OSX来说( 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
},
}],
],
}
]
}


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"
            },
          }],
        ],
    }
    ]
}

这篇关于Node-gyp无法编译nodejs扩展名('fatal error,thread'file not found)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆