Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

electron-rebuild and g++ issue #55

Open
systemmind opened this issue Feb 11, 2021 · 2 comments · May be fixed by #57
Open

electron-rebuild and g++ issue #55

systemmind opened this issue Feb 11, 2021 · 2 comments · May be fixed by #57

Comments

@systemmind
Copy link

I using electron and when I run electron-rebuild command it shows such error:

  CXX(target) Release/obj.target/msgpackBinding/src/msgpack.o                                                                                                                                              
In file included from /home/pi/.electron-gyp/11.2.3/include/node/v8.h:30,                                                                                                                                  
                 from ../src/msgpack.cc:1:                                                                                                                                                                 
/home/pi/.electron-gyp/11.2.3/include/node/v8-internal.h: In function ‘void v8::internal::PerformCastCheck(T*)’:                                                                                           
/home/pi/.electron-gyp/11.2.3/include/node/v8-internal.h:418:38: error: ‘remove_cv_t’ is not a member of ‘std’                                                                                             
             !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);                                                                                                                              
                                      ^~~~~~~~~~~                                                                                                                                                          
/home/pi/.electron-gyp/11.2.3/include/node/v8-internal.h:418:38: note: suggested alternative: ‘remove_cv’                                                                                                  
             !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);                                                                                                                              
                                      ^~~~~~~~~~~                                                                                                                                                          
                                      remove_cv                                                                                                                                                            
/home/pi/.electron-gyp/11.2.3/include/node/v8-internal.h:418:38: error: ‘remove_cv_t’ is not a member of ‘std’                                                                                             
/home/pi/.electron-gyp/11.2.3/include/node/v8-internal.h:418:38: note: suggested alternative: ‘remove_cv’                                                                                                  
             !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);                                                                                                                              
                                      ^~~~~~~~~~~                                                                                                                                                          
                                      remove_cv                                                                                                                                                            
/home/pi/.electron-gyp/11.2.3/include/node/v8-internal.h:418:50: error: template argument 2 is invalid                                                                                                     
             !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);                                                                                                                              
                                                  ^                                                                                                                                                        
/home/pi/.electron-gyp/11.2.3/include/node/v8-internal.h:418:63: error: ‘::Perform’ has not been declared                                                                                                  
             !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);                                                                                                                              
                                                               ^~~~~~~                                                                                                                                     
/home/pi/.electron-gyp/11.2.3/include/node/v8-internal.h:418:63: note: suggested alternative: ‘perror’                                                                                                     
             !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);                                                                                                                              
                                                               ^~~~~~~                                                                                                                                     
                                                               perror

This issue appears because we have -std=c++11 flag in binding.gyp file:

            'cflags_cc': [
                    '-Wall',
                    '-O3',
                    '-std=c++11',
                ],

Changing this flag to -std=c++14 or removing it fixes the issue.

I am working on linux with gcc-8.

@henrychoi7
Copy link

henrychoi7 commented Jun 9, 2021

I have a similar issue here when building with node-gyp manually from the source.

  • Operating system: macOS 11.3.1
  • Apple clang version: 12.0.5 (clang-1205.0.22.9)
# build from the root directory
$ node-gyp rebuild
# or module directory
$ npx node-gyp rebuild -C ./node_modules/msgpack
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp info chdir ./node_modules/msgpack
[...]
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/objectc.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/unpack.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/vrefbuffer.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/zone.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/version.o
  LIBTOOL-STATIC Release/msgpack.a
  CXX(target) Release/obj.target/msgpackBinding/src/msgpack.o
In file included from ../src/msgpack.cc:1:
In file included from /Users/user/Library/Caches/node-gyp/16.1.0/include/node/v8.h:30:
/Users/user/Library/Caches/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
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:776:50: note: 'remove_cv' declared here
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
                                                 ^
1 error generated.
make: *** [Release/obj.target/msgpackBinding/src/msgpack.o] Error 1

As @systemmind said, this issue could be fixed by removing the -std=c++11 in cflags_cc attribute in binding.gyp file. In macOS, I had to remove the 'OTHER_CFLAGS': ['-std=c++11'] options as well.

Fix:

{
    "targets": [
        {
            [...]
            'cflags_cc': [
                    '-Wall',
                    '-O3'
                ],
            [...]
            'conditions': [
                ['OS=="mac"', {
                    'configurations': {
                        'Debug': {
                            'xcode_settings': {
                                'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
                                'WARNING_CFLAGS': ['-Wall', '-Wno-unused-function']
                            }
                        },
                        'Release': {
                            'xcode_settings': {
                                'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
                                'WARNING_CFLAGS': ['-Wall', '-Wno-unused-function']
                            },
                        },
                    },
                }],
               [...]

@godsflaw Can I send a PR for this issue?

@sliterok
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants