简体   繁体   English

在ubuntu上进行npm安装期间,使用内部c ++ 17编译本机节点插件失败

[英]Compiling native node addon with c++ 17 inside fails during npm install on ubuntu

I have native add-on for nodejs that uses c++17 features, specifically "shared_mutex". 我有使用c ++ 17功能(特别是“ shared_mutex”)的nodejs的本机加载项。 When I call npm install which downloads and compiles the add-on i get an error: 当我致电npm install并下载并编译附加组件时,出现错误: 在此处输入图片说明

The linux machine has GCC 6.0 installed. linux计算机已安装GCC 6.0。

My Binding.gyp uses the following config to catch os type and add flags accordingly: 我的Binding.gyp使用以下配置来捕获os类型并相应地添加标志:

     'conditions': [
        ['OS=="linux"', {
            'CXXFLAGS': [
                '-std=c++1z'
            ]}],

** i've also tried with '-std=c++17', '-std=c++1z'. **我也尝试过使用'-std = c ++ 17','-std = c ++ 1z'。

What am I missing? 我想念什么?

Update: 1. Updated ubuntu 16.04 to GCC 16.04 and made it default. 更新:1.将ubuntu 16.04更新为GCC 16.04,并将其设为默认设置。 2. It seems that when i try to compile it manualy using node-gyp rebuild "CXXFLAGS='-std=c++17'" it works and brings only one error: "shared_,utex in namespace std does not name a type std::shared_mutex file mutex" (the last error) 2.似乎当我尝试使用node-gyp手动重建它时,编译“ CXXFLAGS ='-std = c ++ 17'”,它可以正常工作,并且仅带来一个错误:“ shared_,utex在命名空间std中未命名类型std :: shared_mutex文件互斥”(最后一个错误)

Problem solved. 问题解决了。 For anyone who has the same issue, bind.gyp should use cflags_cc instead of cxxflags. 对于有相同问题的任何人,bind.gyp应该使用cflags_cc而不是cxxflags。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM