robertklep / node-metrohash

Node.js bindings for MetroHash
MIT License
26 stars 8 forks source link

NodeJS v16 compilation error: `no template named 'remove_cv_t' in namespace 'std'` #20

Closed laurence-myers closed 3 years ago

laurence-myers commented 3 years ago

On macOS Catalina 10.15.7. Xcode CLT installed on 26/05/21 (AEDT)

gyp info spawn /usr/bin/python2
gyp info spawn args [
gyp info spawn args   '/Users/lmyers/code/foo-project/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/lmyers/code/foo-project/node_modules/metrohash/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/lmyers/code/foo-project/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/lmyers/.node-gyp/16.1.0/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/lmyers/.node-gyp/16.1.0',
gyp info spawn args   '-Dnode_gyp_dir=/Users/lmyers/code/foo-project/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/lmyers/.node-gyp/16.1.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/lmyers/code/foo-project/node_modules/metrohash',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CXX(target) Release/obj.target/metrohash/src/metrohash_wrapper.o
In file included from ../src/metrohash_wrapper.cpp:2:
In file included from ../../nan/nan.h:56:
In file included from /Users/lmyers/.node-gyp/16.1.0/include/node/node.h:63:
In file included from /Users/lmyers/.node-gyp/16.1.0/include/node/v8.h:30:
/Users/lmyers/.node-gyp/16.1.0/include/node/v8-internal.h:452:38: error: no template named 'remove_cv_t' in namespace 'std'; did you mean 'remove_cv'?
            !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
                                ~~~~~^~~~~~~~~~~
                                     remove_cv
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/type_traits:697:50: note: 'remove_cv' declared here
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
                                                 ^
1 error generated.
make: *** [Release/obj.target/metrohash/src/metrohash_wrapper.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2

gcc version:

Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
laurence-myers commented 3 years ago

Looks like the solution is just to upgrade from C++11 to C++14. Seems like a straightforward job to change binding.gyp, but I don't know what other impacts that has.

robertklep commented 3 years ago

@laurence-myers sorry for the delayed response, I'll hopefully have time to look at this somewhere in the upcoming days.

robertklep commented 3 years ago

I just published metrohash@2.7.0 which uses C++14 to build the addon. Seems to work fine on (somewhat) older Node.js and macOS versions too.

laurence-myers commented 3 years ago

Thanks very much @robertklep 😁

I saw that a Travis CI job failed running on "node" (v16). The jobs for other NodeJS versions passed, but I think it's a false positive - seems like in job #64.1, npm ci ran node-gyp, but job #64.2 did not.

metrohash_1

metrohash_2

robertklep commented 3 years ago

Yeah I saw the failed job too 😅 Probably because the g++ version that gets installed is too old.