Search code examples
node.jscentosgcc4.8nodegit

Configure gcc-4.8.5 to include GLIBCXX_3.4.20 on centos6


Hi folks i've been searching for solutions to this problem for days but none of the methods posted online worked for me. Basically I'm trying to install NodeGit library on my production server (centos-release-6-8.el6.centos.12.3.x86_64). Doing npm install throws the following error:

Error: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /home/app/node_modules/nodegit/build/Release/nodegit.node)
    at Error (native)
    at Object.Module._extensions..node (module.js:434:18)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/home/app/node_modules/nodegit/dist/nodegit.js:11:12)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
]
  killed: false,
  code: 1,
  signal: null,
  cmd: '/bin/sh -c node /home/app/node_modules/nodegit/dist/nodegit.js' }

Doing strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX gives:

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_FORCE_NEW
GLIBCXX_DEBUG_MESSAGE_LENGTH

So GLIBCXX_3.4.20 is missing. Running gcc -v gives:

COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/packages/encap/gcc-4.8.5/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.8.5/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.8.5/configure --enable-languages=c,c++,fortran --enable-shared --disable-libstdcxx-pch --enable-lto --enable-libgomp --enable-__cxa_atexit --enable-tls --with-gmp --with-mpfr --with-mpc --with-libelf
Thread model: posix
gcc version 4.8.5 (GCC)

Some places suggest I install gcc-4.9 following this . But it simply doesn't work because in the production server I have to install gcc through a host management tool(Roller) which is a pain in the ass and I want to avoid doing that.

Do you folks know any ways of getting the GLIBCXX_3.4.20 installed?


Solution

  • The GLIBCXX_3.4.20 was added in GCC-4.9 (reference).

    Some places suggest I install gcc-4.9 following this . But it simply doesn't work because in the production server I have to install gcc through a host management tool(Roller) which is a pain in the ass and I want to avoid doing that.

    Somehow, you must get libstdc++.so.6 from GCC-4.9.x (or later) onto the production server, and in a place where your binary will find it.

    If you don't want to use Roller, do it any other way you like.