2016-07-10 40 views
0

我在安裝需要在centos 6.8上編譯的nodejs庫時出現問題。看起來像節點v4依賴關係應該與更新版本的gcc-C++一起編譯。 我按照無數帖子的建議安裝了devtoolset v3,以便能夠使用gcc-4.9。但它仍然失敗,同樣的錯誤消息暗示我仍在使用不支持C++ 11的編譯器。 我沒有strace的,它看起來像devtools不提供libgcc的地方安裝過程中希望能夠找到它,所以它最終採取定期之一,它是gcc-4.4在centos上編譯爲nodejs v4 6.8

設置:

[[email protected] sflow]$ cat /etc/centos-release 
CentOS release 6.8 (Final) 
[[email protected] sflow]$ node -v 
v4.4.7 
[[email protected] sflow]$ npm -v 
2.15.8 

無devtoolset:

[[email protected] 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安裝

[[email protected] sflow]$ npm instal --save pcap2 
npm WARN package.json [email protected] No description 
npm WARN package.json [email protected] No repository field. 
npm WARN package.json [email protected] No README data 
\ 
> [email protected] 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! [email protected] install: `node-gyp rebuild` 
npm ERR! Exit status 1 
npm ERR! 
npm ERR! Failed at the [email protected] 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:

[[email protected] sflow]$ scl enable python27 devtoolset-3 bash 
[[email protected] 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安裝

[[email protected] sflow]$ npm install --save pcap2 
npm WARN package.json [email protected] No description 
npm WARN package.json [email protected] No repository field. 
npm WARN package.json [email protected] No README data 
- 
> [email protected] 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! [email protected] install: `node-gyp rebuild` 
npm ERR! Exit status 1 
npm ERR! 
npm ERR! Failed at the [email protected] 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的:

[[email protected] sflow]$ strace npm install --save pcap2 > strace.log 2>&1 
[[email protected] 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 

節點GYP重建

[[email protected] 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) 
[[email protected] sflow]$ env CXX="g++ -v" node-gyp rebuild 
gyp info it worked if it ends with ok 
gyp info using [email protected] 
gyp info using [email protected] | 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 

所以,問題是 - 什麼是我在運用devtoolset對centos6使用gcc-4.9不見了? 還是有另一種方式來節點v4和pcap2在centos6上?

+1

是否實際安裝失敗?您嘗試運行的'npm'命令的實際輸出是什麼?在不同的目錄中搜索'libgcc_s.so.1'在這裏並不是真正的問題,我認爲這是一個紅鯡魚。請向我們展示'npm'命令的實際輸出。 –

+0

@JoachimPileborg,完成。 – ilj

+0

這裏的問題是你的GCC版本。版本4.4.7只是爲了支持C++ 11。 –

回答

1

需要C++ 11兼容的編譯器(例如gcc 4.8或更高版本)。在帖子末尾的node-gyp rebuild輸出中,它看起來並不像你的4.9.2安裝得到提升。您可以使用env CC=/path/to/gcc CXX=/path/to/g++ LINKXX=/path/to/g++ LINK=/path/to/gcc node-gyp rebuild來將顯式路徑設置爲正確的gcc/g ++二進制文件。

(原文評論,現在張貼的答案。)