简体   繁体   中英

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". When I call npm install which downloads and compiles the add-on i get an error: 在此处输入图片说明

The linux machine has GCC 6.0 installed.

My Binding.gyp uses the following config to catch os type and add flags accordingly:

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

** i've also tried with '-std=c++17', '-std=c++1z'.

What am I missing?

Update: 1. Updated ubuntu 16.04 to GCC 16.04 and made it default. 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)

Problem solved. For anyone who has the same issue, bind.gyp should use cflags_cc instead of cxxflags.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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