I'm having issues installing nodejs libraries that require compilation on centos 6.8. looks like node v4 dependencies should be compiled with newer version of gcc-c++. I installed devtoolset v3 as suggested in numerous posts, to be able to use gcc-4.9. But it still fails with same error messages suggesting i'm still using a compiler that does not support c++11. I did strace and it looks like devtools does not provide libgcc where installation process expects to find it, so it ends up taking the regular one, which is gcc-4.4
setup:
[vagrant@localhost sflow]$ cat /etc/centos-release
CentOS release 6.8 (Final)
[vagrant@localhost sflow]$ node -v
v4.4.7
[vagrant@localhost sflow]$ npm -v
2.15.8
without devtoolset:
[vagrant@localhost sflow]$ g++ -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC)
npm install
[vagrant@localhost sflow]$ npm instal --save pcap2
npm WARN package.json sflow@1.0.0 No description
npm WARN package.json sflow@1.0.0 No repository field.
npm WARN package.json sflow@1.0.0 No README data
\
> socketwatcher@0.3.0 install /home/vagrant/sflow/node_modules/pcap2/node_modules/socketwatcher
> node-gyp rebuild
make: Entering directory `/home/vagrant/sflow/node_modules/pcap2/node_modules/socketwatcher/build'
CXX(target) Release/obj.target/socketwatcher/socket_watcher.o
In file included from ../socket_watcher.hpp:8,
from ../socket_watcher.cpp:5:
../../nan/nan.h:43:3: error: #error This version of node/NAN/v8 requires a C++11 compiler
In file included from /home/vagrant/.node-gyp/4.4.7/include/node/node.h:42,
from ../../nan/nan.h:47,
from ../socket_watcher.hpp:8,
from ../socket_watcher.cpp:5:
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h:336: error: expected unqualified-id before ‘using’
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h: In constructor ‘v8::MaybeLocal<T>::MaybeLocal()’:
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h:353: error: ‘nullptr’ was not declared in this scope
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h: In member function ‘bool v8::MaybeLocal<T>::IsEmpty() const’:
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h:360: error: ‘nullptr’ was not declared in this scope
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h: In member function ‘bool v8::MaybeLocal<T>::ToLocal(v8::Local<S>*) const’:
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h:364: error: ‘nullptr’ was not declared in this scope
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h: In member function ‘bool v8::WeakCallbackInfo<T>::IsFirstPass() const’:
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h:430: error: ‘nullptr’ was not declared in this scope
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h: At global scope:
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h:469: error: expected unqualified-id before ‘using’
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h: In constructor ‘v8::Global<T>::Global()’:
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h:790: error: ‘nullptr’ was not declared in this scope
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h: In constructor ‘v8::Global<T>::Global(v8::Global<T>&&)’:
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h:815: error: ‘nullptr’ was not declared in this scope
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h: In member function ‘v8::Global<T>& v8::Global<T>::operator=(v8::Global<S>&&)’:
... skipped ...
../../nan/nan.h:2256: error: expected unqualified-id before ‘>’ token
../../nan/nan.h:2265: error: expected constructor, destructor, or type conversion before ‘<’ token
../socket_watcher.cpp: In static member function ‘static void SocketWatcher::Initialize(v8::Local<v8::Object>)’:
../socket_watcher.cpp:22: error: ‘class v8::Local<v8::Boolean>’ has no member named ‘ToLocalChecked’
../socket_watcher.cpp:30: error: ‘class v8::Local<v8::Boolean>’ has no member named ‘ToLocalChecked’
../socket_watcher.cpp: In static member function ‘static void SocketWatcher::Callback(uv_poll_t*, int, int)’:
../socket_watcher.cpp:62: error: ‘class v8::Local<v8::Boolean>’ has no member named ‘ToLocalChecked’
../socket_watcher.cpp:63: error: ‘Get’ is not a member of ‘Nan’
make: *** [Release/obj.target/socketwatcher/socket_watcher.o] Error 1
make: Leaving directory `/home/vagrant/sflow/node_modules/pcap2/node_modules/socketwatcher/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 2.6.32-642.el6.x86_64
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/vagrant/sflow/node_modules/pcap2/node_modules/socketwatcher
gyp ERR! node -v v4.4.7
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
npm ERR! Linux 2.6.32-642.el6.x86_64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "instal" "--save" "pcap2"
npm ERR! node v4.4.7
npm ERR! npm v2.15.8
npm ERR! code ELIFECYCLE
npm ERR! socketwatcher@0.3.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the socketwatcher@0.3.0 install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the socketwatcher package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs socketwatcher
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls socketwatcher
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/vagrant/sflow/npm-debug.log
devtoolset:
[vagrant@localhost sflow]$ scl enable python27 devtoolset-3 bash
[vagrant@localhost sflow]$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-3/root/usr/libexec/gcc/x86_64-redhat-linux/4.9.2/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/opt/rh/devtoolset-3/root/usr --mandir=/opt/rh/devtoolset-3/root/usr/share/man --infodir=/opt/rh/devtoolset-3/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --enable-languages=c,c++,fortran,lto --enable-plugin --with-linker-hash-style=gnu --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.9.2-20150212/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.9.2-20150212/obj-x86_64-redhat-linux/cloog-install --with-mpc=/builddir/build/BUILD/gcc-4.9.2-20150212/obj-x86_64-redhat-linux/mpc-install --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.9.2 20150212 (Red Hat 4.9.2-6) (GCC)
npm install
[vagrant@localhost sflow]$ npm install --save pcap2
npm WARN package.json sflow@1.0.0 No description
npm WARN package.json sflow@1.0.0 No repository field.
npm WARN package.json sflow@1.0.0 No README data
-
> socketwatcher@0.3.0 install /home/vagrant/sflow/node_modules/pcap2/node_modules/socketwatcher
> node-gyp rebuild
make: Entering directory `/home/vagrant/sflow/node_modules/pcap2/node_modules/socketwatcher/build'
CXX(target) Release/obj.target/socketwatcher/socket_watcher.o
In file included from ../socket_watcher.hpp:8,
from ../socket_watcher.cpp:5:
../../nan/nan.h:43:3: error: #error This version of node/NAN/v8 requires a C++11 compiler
In file included from /home/vagrant/.node-gyp/4.4.7/include/node/node.h:42,
from ../../nan/nan.h:47,
from ../socket_watcher.hpp:8,
from ../socket_watcher.cpp:5:
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h:336: error: expected unqualified-id before ‘using’
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h: In constructor ‘v8::MaybeLocal<T>::MaybeLocal()’:
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h:353: error: ‘nullptr’ was not declared in this scope
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h: In member function ‘bool v8::MaybeLocal<T>::IsEmpty() const’:
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h:360: error: ‘nullptr’ was not declared in this scope
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h: In member function ‘bool v8::MaybeLocal<T>::ToLocal(v8::Local<S>*) const’:
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h:364: error: ‘nullptr’ was not declared in this scope
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h: In member function ‘bool v8::WeakCallbackInfo<T>::IsFirstPass() const’:
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h:430: error: ‘nullptr’ was not declared in this scope
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h: At global scope:
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h:469: error: expected unqualified-id before ‘using’
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h: In constructor ‘v8::Global<T>::Global()’:
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h:790: error: ‘nullptr’ was not declared in this scope
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h: In constructor ‘v8::Global<T>::Global(v8::Global<T>&&)’:
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h:815: error: ‘nullptr’ was not declared in this scope
/home/vagrant/.node-gyp/4.4.7/include/node/v8.h: In member function ‘v8::Global<T>& v8::Global<T>::operator=(v8::Global<S>&&)’:
... skipped ...
../../nan/nan.h:2256: error: ‘MaybeLocal’ was not declared in this scope
../../nan/nan.h:2256: error: template argument 1 is invalid
../../nan/nan.h:2256: error: expected unqualified-id before ‘>’ token
../../nan/nan.h:2265: error: expected constructor, destructor, or type conversion before ‘<’ token
../socket_watcher.cpp: In static member function ‘static void SocketWatcher::Initialize(v8::Local<v8::Object>)’:
../socket_watcher.cpp:22: error: ‘class v8::Local<v8::Boolean>’ has no member named ‘ToLocalChecked’
../socket_watcher.cpp:30: error: ‘class v8::Local<v8::Boolean>’ has no member named ‘ToLocalChecked’
../socket_watcher.cpp: In static member function ‘static void SocketWatcher::Callback(uv_poll_t*, int, int)’:
../socket_watcher.cpp:62: error: ‘class v8::Local<v8::Boolean>’ has no member named ‘ToLocalChecked’
../socket_watcher.cpp:63: error: ‘Get’ is not a member of ‘Nan’
make: *** [Release/obj.target/socketwatcher/socket_watcher.o] Error 1
make: Leaving directory `/home/vagrant/sflow/node_modules/pcap2/node_modules/socketwatcher/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 2.6.32-642.el6.x86_64
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/vagrant/sflow/node_modules/pcap2/node_modules/socketwatcher
gyp ERR! node -v v4.4.7
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
npm ERR! Linux 2.6.32-642.el6.x86_64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "--save" "pcap2"
npm ERR! node v4.4.7
npm ERR! npm v2.15.8
npm ERR! code ELIFECYCLE
npm ERR! socketwatcher@0.3.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the socketwatcher@0.3.0 install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the socketwatcher package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs socketwatcher
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls socketwatcher
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/vagrant/sflow/npm-debug.log
strace:
[vagrant@localhost sflow]$ strace npm install --save pcap2 > strace.log 2>&1
[vagrant@localhost sflow]$ grep gcc strace.log
open("/opt/rh/devtoolset-3/root/usr/lib64/tls/libgcc_s.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/rh/devtoolset-3/root/usr/lib64/libgcc_s.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/rh/devtoolset-3/root/usr/lib/libgcc_s.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/rh/python27/root/usr/lib64/tls/libgcc_s.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/rh/python27/root/usr/lib64/libgcc_s.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib64/libgcc_s.so.1", O_RDONLY) = 3
node-gyp rebuild
[vagrant@localhost sflow]$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-3/root/usr/libexec/gcc/x86_64-redhat-linux/4.9.2/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/opt/rh/devtoolset-3/root/usr --mandir=/opt/rh/devtoolset-3/root/usr/share/man --infodir=/opt/rh/devtoolset-3/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --enable-languages=c,c++,fortran,lto --enable-plugin --with-linker-hash-style=gnu --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.9.2-20150212/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.9.2-20150212/obj-x86_64-redhat-linux/cloog-install --with-mpc=/builddir/build/BUILD/gcc-4.9.2-20150212/obj-x86_64-redhat-linux/mpc-install --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.9.2 20150212 (Red Hat 4.9.2-6) (GCC)
[vagrant@localhost sflow]$ env CXX="g++ -v" node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using node-gyp@3.4.0
gyp info using node@4.4.7 | linux | x64
gyp info spawn /opt/rh/python27/root/usr/bin/python2
gyp info spawn args [ '/usr/lib/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 '/home/vagrant/sflow/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/home/vagrant/.node-gyp/4.4.7/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/home/vagrant/.node-gyp/4.4.7',
gyp info spawn args '-Dnode_gyp_dir=/usr/lib/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=node.lib',
gyp info spawn args '-Dmodule_root_dir=/home/vagrant/sflow',
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: binding.gyp not found (cwd: /home/vagrant/sflow) while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/lib/node_modules/node-gyp/lib/configure.js:305:16)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 2.6.32-642.el6.x86_64
gyp ERR! command "/usr/bin/node" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/vagrant/sflow
gyp ERR! node -v v4.4.7
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
so, the question is - what am i missing in applying devtoolset to use gcc-4.9 on centos6? or is there another way to node v4 and pcap2 on centos6?
A C++11-compatible compiler is required (e.g. gcc 4.8 or later). In the node-gyp rebuild
output at the end of your post, it still doesn't look like your 4.9.2 installation got picked up. You can set explicit paths to the correct gcc/g++ binaries using env CC=/path/to/gcc CXX=/path/to/g++ LINKXX=/path/to/g++ LINK=/path/to/gcc node-gyp rebuild
.
(Originally a comment, now posted as an answer.)