1

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: enter image description here

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)

5
  • Firstly, c++1y is 14 not 17, 17 would be 1z. Secondly, try using cxxflags instead of cflags.
    – fmorgner
    Aug 15, 2017 at 5:54
  • Do you see the -std=c++1y passed to gcc while compiling. The gcc command will be just above the error messages
    – Malice
    Aug 15, 2017 at 5:56
  • shared_mutex was added in 6.1. (Note that the C++17 standard isn't finished yet. Compiler support is unpredictable.)
    – molbdnilo
    Aug 15, 2017 at 6:02
  • updated to CXXFLAGS="-std=c++1z" - still doesn't pass the flags.
    – YafimK
    Aug 15, 2017 at 6:18
  • i've updated the GCC to 6.3 but it still doesn't work with same error. But it seem to partly work when i manually "node-gyp rebuild CXXFLAGS=-std=c++17"
    – YafimK
    Aug 15, 2017 at 6:19

1 Answer 1

2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.