如何编译 node.js for CentOS 6.10 (库问题)

How to compile node.js for CentOS 6.10 (library issues)

本文关键字:CentOS 问题 for node 何编译 编译 js      更新时间:2023-10-16

我正在尝试让最新版本的节点(目前为 12.1.0)在 CentOS 6.10 盒子上运行。 这是一个问题,因为标准的 CentOS 二进制文件已过时;例如:

./node: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by ./node)
(a number of other references like this also appear)

当我尝试安装和运行二进制文件时,g++/c ++工具已过时。 但是我决定尝试从源代码编译,如果我能让工具正确对齐的话。

我已经从 CERN devtools(http://linux.web.cern.ch/linux/devtoolset)获得了编译器工具的更新版本,并且似乎已经正确安装了它们。 我从网络上的各个地方得到的是,在进行配置之前,我需要导出指向这些新库的指针,例如:

export CC=/opt/rh/devtoolset-2/root/usr/bin/gcc  
export CPP=/opt/rh/devtoolset-2/root/usr/bin/cpp
export CXX=/opt/rh/devtoolset-2/root/usr/bin/c++

这些确实具有更新和足够现代的版本,例如,

/opt/rh/devtoolset-2/root/usr/bin/c++ --version
c++ (GCC) 4.8.2 20140120 (Red Hat 4.8.2-15)

但他们似乎没有进入配置过程:

[root@linux2 node-v12.1.0]# ./configure --prefix=/opt/node-12.1.0
WARNING: C++ compiler too old, need g++ 6.3.0 or clang++ 8.0.0 (CXX=/opt/rh/devtoolset-2/root/usr/bin/c++)
INFO: Using floating patch "tools/icu/patches/64/source/common/putil.cpp" from "tools/icu"
INFO: Using floating patch "tools/icu/patches/64/source/i18n/dtptngen.cpp" from "tools/icu"
WARNING: warnings were emitted in the configure phase
INFO: configure completed successfully

当我交叉手指并尝试make时,我得到了一大堆编译结果,然后是一堆错误,为了简洁起见,这里(暂时)省略了。

无论如何:它只是不起作用。 谁能看到这里发生了什么,以及我如何把事情做好? 谢谢!

你需要一个更新的开发工具集,6 或 7 而不是 2。此链接应该会有所帮助。并按照建议使用scl,而不是自己设置 env var。