node.js源碼編譯快速安裝

官網:node

https://nodejs.org/en/linux

1-系統環境c++

2-下載安裝git

wget https://github.com/nodejs/node/archive/v6.9.4.tar.gzgithub

3-解壓並編譯安裝express

tar -zxf v6.9.4.tar.gz ide

cd node-6.9.4ui

./configure this

makespa

make install

=====================

源碼包安裝,解壓就能夠使用

下載包 node-v6.9.4-linux-x64.tar.xz

解壓 tar -xf node-v6.9.4-linux-x64.tar.xz

將bin目錄加入PATH環境變量

echo $PATH
/usr/local/node/node-v6.9.1-linux-x64/bin:

=====================

 

 

==========編譯make報錯一==========

解決辦法,升級gcc 到4.8以上

../deps/v8/src/base/logging.h:131: error: ‘nullptr’ was not declared in this scope
In file included from ../deps/v8/src/libplatform/default-platform.h:15,

 from ../deps/v8/src/libplatform/default-platform.cc:5:
../deps/v8/src/base/platform/mutex.h: At global scope:
../deps/v8/src/base/platform/mutex.h:36: error: variable ‘v8::base::Mutex v8::base::final’ has initializer but incomplete type
../deps/v8/src/base/platform/mutex.h:37: error: expected primary-expression before ‘public’
../deps/v8/src/base/platform/mutex.h:37: error: expected ‘}’ before ‘public’
../deps/v8/src/base/platform/mutex.h:37: error: expected ‘,’ or ‘;’ before ‘public’
../deps/v8/src/base/platform/mutex.h:39: error: expected constructor, destructor, or type conversion before ‘;’ token
../deps/v8/src/base/platform/mutex.h: In function ‘v8::base::NativeHandle& v8::base::native_handle()’:
../deps/v8/src/base/platform/mutex.h:63: error: ‘native_handle_’ was not declared in this scope
../deps/v8/src/base/platform/mutex.h: At global scope:
../deps/v8/src/base/platform/mutex.h:65: error: non-member function ‘const v8::base::NativeHandle& v8::base::native_handle()’ cannot have cv-qualifier
../deps/v8/src/base/platform/mutex.h: In function ‘const v8::base::NativeHandle& v8::base::native_handle()’:
../deps/v8/src/base/platform/mutex.h:65: error: new declaration ‘const v8::base::NativeHandle& v8::base::native_handle()’
../deps/v8/src/base/platform/mutex.h:62: error: ambiguates old declaration ‘v8::base::NativeHandle& v8::base::native_handle()’
../deps/v8/src/base/platform/mutex.h:66: error: ‘native_handle_’ was not declared in this scope
../deps/v8/src/base/platform/mutex.h: At global scope:
../deps/v8/src/base/platform/mutex.h:69: error: expected unqualified-id before ‘private’
../deps/v8/src/base/platform/mutex.h:89: error: ‘friend’ used outside of class
../deps/v8/src/base/platform/mutex.h:91: error: expected unqualified-id before ‘const’
../deps/v8/src/base/platform/mutex.h:91: error: expected ‘)’ before ‘const’
../deps/v8/src/base/platform/mutex.h:91: error: ‘void v8::base::operator=(const v8::base::Mutex&)’ must be a nonstatic member function
../deps/v8/src/base/platform/mutex.h:104: error: expected initializer before ‘<’ token
../deps/v8/src/base/platform/mutex.h:130: error: variable ‘v8::RecursiveMutex v8::final’ has initializer but incomplete type
../deps/v8/src/base/platform/mutex.h:131: error: expected primary-expression before ‘public’
../deps/v8/src/base/platform/mutex.h:131: error: expected ‘}’ before ‘public’
../deps/v8/src/base/platform/mutex.h:131: error: expected ‘,’ or ‘;’ before ‘public’
../deps/v8/src/base/platform/mutex.h:133: error: expected constructor, destructor, or type conversion before ‘;’ token
../deps/v8/src/base/platform/mutex.h:155: error: ‘Mutex’ has not been declared
../deps/v8/src/base/platform/mutex.h:155: error: expected initializer before ‘NativeHandle’
../deps/v8/src/base/platform/mutex.h:157: error: expected constructor, destructor, or type conversion before ‘&’ token
../deps/v8/src/base/platform/mutex.h:160: error: expected initializer before ‘&’ token
../deps/v8/src/base/platform/mutex.h:164: error: expected unqualified-id before ‘private’
../deps/v8/src/base/platform/mutex.h:170: error: expected unqualified-id before ‘const’
../deps/v8/src/base/platform/mutex.h:170: error: expected ‘)’ before ‘const’
../deps/v8/src/base/platform/mutex.h:170: error: ‘void v8::operator=(const v8::RecursiveMutex&)’ must be a nonstatic member function
../deps/v8/src/base/platform/mutex.h:184: error: expected initializer before ‘<’ token
../deps/v8/src/base/platform/mutex.h:202: error: template declaration of ‘LockGuard final’
../deps/v8/src/base/platform/mutex.h:203: error: expected primary-expression before ‘public’
../deps/v8/src/base/platform/mutex.h:203: error: expected ‘}’ before ‘public’
../deps/v8/src/base/platform/mutex.h:205: error: declaration of ‘~LockGuard’ as non-member
../deps/v8/src/base/platform/mutex.h:207: error: expected unqualified-id before ‘private’
../deps/v8/src/base/platform/mutex.h:210: error: expected unqualified-id before ‘const’
../deps/v8/src/base/platform/mutex.h:210: error: expected ‘)’ before ‘const’
../deps/v8/src/base/platform/mutex.h:210: error: ‘void operator=(const LockGuard&)’ must be a nonstatic member function
../deps/v8/src/base/platform/mutex.h:211: error: expected declaration before ‘}’ token
make[1]:***[/home/lsug/node-6.9.4/out/Release/obj.target/v8_libplatform/deps/v8/src/libplatform/default-platform.o] Error 1
make[1]: Leaving directory `/home/lsug/node-6.9.4/out'
make: *** [node] Error 2

============報錯二=====
/home/lsug/node-6.9.4/out/Release/mksnapshot: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /home/lsug/node-6.9.4/out/Release/mksnapshot)
/home/lsug/node-6.9.4/out/Release/mksnapshot: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /home/lsug/node-6.9.4/out/Release/mksnapshot)
/home/lsug/node-6.9.4/out/Release/mksnapshot: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /home/lsug/node-6.9.4/out/Release/mksnapshot)
make[1]: *** [/home/lsug/node-6.9.4/out/Release/obj.target/v8_snapshot/geni/snapshot.cc] Error 1
make[1]: Leaving directory `/home/lsug/node-6.9.4/out'
make: *** [node] Error 2

緣由:

升級gcc生成的動態庫沒有替換老版本gcc的動態庫

解決辦法:

升級gcc,生成的動態庫沒有替換老版本gcc的動態庫

源碼編譯升級安裝了gcc後,編譯程序或運行其它程序時,有時會出現相似/usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found的問題。這是由於升級gcc時,生成的動態庫沒有替換老版本gcc的動態庫致使的,將gcc最新版本的動態庫替換系統中老版本的動態庫便可解決。

 運行如下命令檢查動態庫:

strings /usr/lib64/libstdc++.so.6 | grep GLIBC

從輸出能夠看出,gcc的動態庫仍是舊版本的。說明出現這些問題,是由於升級gcc時,生成的動態庫沒有替換老版本gcc的動態庫。

查找編譯gcc時生成的最新動態庫:

find / -name "libstdc++.so*"

將上面的最新動態庫libstdc++.so.6.0.22複製到/usr/lib64目錄下

cd /usr/lib64

sudo cp /home/lsug/gcc-6.1.0/gcc-build-6.1.0/stage1-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.22 ./

 刪除原來軟鏈接:

rm -rf libstdc++.so.6

將默認庫的軟鏈接指向最新動態庫:

ln -s libstdc++.so.6.0.22 libstdc++.so.6

默認動態庫升級完成。從新運行如下命令檢查動態庫:

strings /usr/lib64/libstdc++.so.6 | grep GLIBC

[lsug@minion node-6.9.4]$ strings /usr/lib64/libstdc++.so.6 | grep GLIBC
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19
GLIBCXX_3.4.20
GLIBCXX_3.4.21

GLIBCXX_3.4.22
GLIBC_2.3
GLIBC_2.2.5
GLIBC_2.3.2
GLIBCXX_FORCE_NEW
GLIBCXX_DEBUG_MESSAGE_LENGTH

能夠看到 輸出有"GLIBCXX_3.4.15,20和21" 了

相關文章
相關標籤/搜索