nodejs最新版本安装相关依赖问题

 后端   大苹果   2023-12-02 23:03   265

近期经常遇到使用源码编译的部署方式进行应用部署,在 GCC 编译环境上遇到各种问题,本文对升级部署 GCC 编译环境的流程以及遇到的一些问题进行记录。

一、python3
gcc 11.2 安装需要 python3

yum install -y python3-devel

二、升级 Make

查看版本

make -v

# 查看版本
make -v

# 下载
wget http://ftp.gnu.org/pub/gnu/make/make-4.3.tar.gz

# 解压
tar -zxvf make-4.3.tar.gz
cd make-4.3

# 编译
./configure  --prefix=/usr/local/make
make
make install

# 应用
# 找一下都有哪些 make
whereis make

cd /usr/bin/
# 把默认的 make 改名 
mv make make.bak
# 建立一个软连接
ln -sv /usr/local/make/bin/make /usr/bin/make
# 查看一下大功告成
make -v

三、安装GMP、PMFR、MPC

升级 GCC 时需要

yum -y install gmp-devel
yum -y install mpfr-devel
yum -y install libmpc-devel

四、升级GCC

GCC 和 GLIBC 版本有关联,升级 GCC 前需要先确定 GLIBC 的版本,如 Glibc 2.28 对应要求的 GCC 版本为 8.2

# 查看版本
gcc -v

# 下载
wget http://ftp.gnu.org/gnu/gcc/gcc-11.2.0/gcc-11.2.0.tar.gz

# 解压
tar -zxvf gcc-11.2.0.tar.gz
cd gcc-11.2.0

# 下载四个依赖包
./contrib/download_prerequisites

# 编译
mkdir build
cd build/

../configure -enable-checking=release -enable-languages=c,c++ -disable-multilib
make -j16
make install

# 卸载旧版本
yum -y remove gcc g++

# 配置新版本全局可用
ln -s /usr/local/bin/gcc /usr/bin/gcc
ln -s /usr/local/bin/g++ /usr/bin/g++

#  更新动态库
# 查看当前的动态库
strings /usr/lib64/libstdc++.so.6 | grep CXXABI
# 更新
rm -f /usr/lib64/libstdc++.so.6
ln -s /usr/local/lib64/libstdc++.so.6.0.29 /usr/lib64/libstdc++.so.6
# 查看更新后的动态库
strings /usr/lib64/libstdc++.so.6 | grep CXXABI

五、GLIBC

GLIBC下载地址:http://ftp.gnu.org/gnu/glibc/

nodejs 最新版本 服务需要 2.18、 2.25、 2.28

# 查看已安装的glibc
strings /usr/lib64/libc.so.6 |grep  ^GLIBC_

# 下载
wget http://ftp.gnu.org/gnu/glibc/glibc-2.33.tar.xz

# 又重新安装回了GCC貌似覆盖了原先的升级
yum groupinstall "Development Tools" -y

# 解压
xz -d glibc-2.33.tar.xz
tar -xvf glibc-2.33.tar

# 安装
cd glibc-2.33
mkdir build
cd build
../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
make -j16
sed -i '128i\        && $name ne "nss_test2"' ../scripts/test-installation.pl
make install

报错:glibc /usr/bin/ld: cannot find -lnss_test2

原因在于找不到lnss_test2 文件:

解决:

cd ../回到上级目录, vi scripts/test-installation.pl打开文本

定位到128行

  && $name ne "db1"
  && $name ne "thread_db"
  && $name ne "nss_test1"

文本,在中间加一行  && $name ne "nss_test2",保存

make install
  • 2024-09-14 17:24

    打工人

    /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20‘ not found
    
    find / -name libstdc++.so.6*
    /root/gcc-11.2.0/build/prev-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.29
    /root/gcc-11.2.0/build/prev-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6
    /root/gcc-11.2.0/build/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.29
    /root/gcc-11.2.0/build/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6
    /root/gcc-11.2.0/build/stage1-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.29
    /root/gcc-11.2.0/build/stage1-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6
    /usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.py
    /usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.pyc
    /usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.pyo
    /usr/local/lib64/libstdc++.so.6.0.29
    /usr/local/lib64/libstdc++.so.6
    /usr/local/lib64/libstdc++.so.6.0.29-gdb.py
    /usr/lib64/libstdc++.so.6
    /usr/lib64/libstdc++.so.6.0.19
    # 解决方案
    cp /usr/local/lib64/libstdc++.so.6.0.29 /usr/lib64/
    rm -rf /usr/lib64/libstdc++.so.6
    ln -s /usr/lib64/libstdc++.so.6.0.29 /usr/lib64/libstdc++.so.6
    
    strings /usr/lib64/libstdc++.so.6 |grep GLIBCXX*
    
    问题解决
    

  • 2024-09-14 16:30

    打工人

    glibc-2.28安装

    checking version of sed... 4.2.2, ok
    checking for gawk... gawk
    checking version of gawk... 4.0.2, ok
    checking for bison... no
    checking if gcc -B/usr/bin/ is sufficient to build libc... yes
    checking for nm... nm
    checking for python3... python3
    configure: error: 
    *** These critical programs are missing or too old: bison
    *** Check the INSTALL file for required versions.
    

    yum install bison

  • 2024-09-14 08:41

    打工人

    checking whether g++ supports C++11 features by default... no
    checking whether g++ supports C++11 features with -std=gnu++11... no
    checking whether g++ supports C++11 features with -std=gnu++0x... no
    checking whether g++ supports C++11 features with -std=c++11... no
    checking whether g++ supports C++11 features with +std=c++11... no
    checking whether g++ supports C++11 features with -h std=c++11... no
    checking whether g++ supports C++11 features with -std=c++0x... no
    checking whether g++ supports C++11 features with +std=c++0x... no
    checking whether g++ supports C++11 features with -h std=c++0x... no
    configure: error: *** A compiler with support for C++11 language features is required.
    

    yum install gcc-c++ -y

  • 2024-09-14 08:28

    打工人

    [root@iZbp16vrn29z36sbhi3xv6Z gcc-11.2.0]# ./contrib/download_prerequisites
    2024-09-14 08:24:42 URL:https://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2 [2383840/2383840] -> "gmp-6.1.0.tar.bz2" [1]
    2024-09-14 08:24:46 URL:https://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.6.tar.bz2 [1287202/1287202] -> "mpfr-3.1.6.tar.bz2" [1]
    2024-09-14 08:24:50 URL:https://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz [669925/669925] -> "mpc-1.0.3.tar.gz" [1]
    2024-09-14 08:24:53 URL:https://gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2 [1658291/1658291] -> "isl-0.18.tar.bz2" [1]
    gmp-6.1.0.tar.bz2: OK
    mpfr-3.1.6.tar.bz2: OK
    mpc-1.0.3.tar.gz: OK
    isl-0.18.tar.bz2: OK
    ./contrib/download_prerequisites: line 260: bzip2: command not found
    tar: This does not look like a tar archive
    tar: Exiting with failure status due to previous errors
    error: Cannot extract package from gmp-6.1.0.tar.bz2
    

    yum install bzip2