Automattic / node-canvas

Node canvas is a Cairo backed Canvas implementation for NodeJS.
10.2k stars 1.17k forks source link

Cannot get canvas running on CentOS 7 #1796

Open Commandtechno opened 3 years ago

Commandtechno commented 3 years ago

I have been trying to get node canvas to work on CentOS 7 yet I keep getting this error that libstdc.6.so version CXXABI 1.3.9 is not found, from checking the version with strings /lib64/libstdc++.so.6 | grep CXXABI it lists the versions from 1.3 to 1.3.7. I found 1.3 - 1.3.10 in <project directory>/node_modules/canvas/build/Release/libstdc.so.6. I was wondering if anybody has had similar issues and know a fix, a way to redirect it to use that file (I tried LD_LIBRARY_PATH, but it didn't seem to do anything), or anything that could help. I also have the full console log below if it helps.

Issue or Feature

[server]$ node .
node:internal/modules/cjs/loader:1161
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /home/username/server/node_modules/canvas/build/Release/canvas.node)
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1161:18)
    at Module.load (node:internal/modules/cjs/loader:967:32)
    at Function.Module._load (node:internal/modules/cjs/loader:807:14)
    at Module.require (node:internal/modules/cjs/loader:991:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object.<anonymous> (/home/username/server/node_modules/canvas/lib/bindings.js:3:18)
    at Module._compile (node:internal/modules/cjs/loader:1102:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1131:10)
    at Module.load (node:internal/modules/cjs/loader:967:32)
    at Function.Module._load (node:internal/modules/cjs/loader:807:14) {
  code: 'ERR_DLOPEN_FAILED'
}

Steps to Reproduce

const canvas = require('canvas')
npm i canvas
node .

Your Environment

ty image

wesleimarinho commented 3 years ago

Downgrading to canvas 2.6.1 solves the problem while we don't get it fixed on newest version (2.7.0).

Commandtechno commented 3 years ago

I seem to be getting the same issue, am I doing something wrong?

node:internal/modules/cjs/loader:1161
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /home/username/project/node_modules/canvas/build/Release/canvas.node)
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1161:18)
    at Module.load (node:internal/modules/cjs/loader:967:32)
    at Function.Module._load (node:internal/modules/cjs/loader:807:14)
    at Module.require (node:internal/modules/cjs/loader:991:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object.<anonymous> (/home/username/project/node_modules/canvas/lib/bindings.js:3:18)
    at Module._compile (node:internal/modules/cjs/loader:1102:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1131:10)
    at Module.load (node:internal/modules/cjs/loader:967:32)
    at Function.Module._load (node:internal/modules/cjs/loader:807:14) {
  code: 'ERR_DLOPEN_FAILED'
}

[server]$ npm ls canvas
project@1.0.0 /home/username/project
└── canvas@2.6.1
njh commented 3 years ago

I have also experienced this problem on CentOS Linux release 7.6.1810 (Core).

I have worked around this by rebuilding the binary in my project after doing npm install:

npx node-pre-gyp rebuild -C ./node_modules/canvas

I'm not sure if there is a way of telling npm to install from source in my package.json?

sinbargit commented 3 years ago

any update?

ABValois commented 3 years ago

Seems like this problem is a similar to this issue on the VSCode repository (linked because it has loads of great discussion about the cause of the problem). I have spent a few hours today trying to fix this in a docker environment running CentOS Linux release 7.9.2009 (Core) and, like in the issue I linked, running the following reveals the missing CXXABI version (note the absence of 1.3.9, added in a version of gcc that CentOS 7 does not include):

$ strings /lib64/libstdc++.so.6 | grep CXXABI
CXXABI_1.3
CXXABI_1.3.1
CXXABI_1.3.2
CXXABI_1.3.3
CXXABI_1.3.4
CXXABI_1.3.5
CXXABI_1.3.6
CXXABI_1.3.7
CXXABI_TM_1
zbjornson commented 3 years ago

I don't think this is something that any of the maintainers have capacity to work on unfortunately (I don't, at least). For Canvas 2.7.0 we had to upgrade the OS used for prebuilds to support the current versions of Node.js, which apparently used a newer CXXABI than CentOS 7 has. Using Canvas 2.6 should work, as should building from source following the steps in the readme.

I'm not sure if there is a way of telling npm to install from source in my package.json?

It should already be trying to build from source if it can't install a prebuild: https://github.com/Automattic/node-canvas/blob/6bbc8cbd464ff4adc121497fa226d63f1a483f8e/package.json#L32

njh commented 3 years ago

It should already be trying to build from source if it can't install a prebuild

It does successfully download/install the binary. But the binary doesn't work because of the ABI issues. Would be really handy if there was a way of telling it not to use the binary for node-canvas and always compile from source, to work around this problem.

I am not in a hurry to upgrade to CentOS 8, because it reaches end-of-life before CentOS 7 😞

Gwynbleidd79 commented 3 years ago

I'm getting this error too with 2.7.0 and 2.8.0, i can't use 2.6.1 couse node v16.6.1 don't support it

stringang commented 3 years ago

Seems like this problem is a similar to this issue on the VSCode repository (linked because it has loads of great discussion about the cause of the problem). I have spent a few hours today trying to fix this in a docker environment running CentOS Linux release 7.9.2009 (Core) and, like in the issue I linked, running the following reveals the missing CXXABI version (note the absence of 1.3.9, added in a version of gcc that CentOS 7 does not include):

$ strings /lib64/libstdc++.so.6 | grep CXXABI
CXXABI_1.3
CXXABI_1.3.1
CXXABI_1.3.2
CXXABI_1.3.3
CXXABI_1.3.4
CXXABI_1.3.5
CXXABI_1.3.6
CXXABI_1.3.7
CXXABI_TM_1

Is the problem now solved?

stringang commented 3 years ago

this is my solution in Centos7:

1. Manually upgrade the GCC version

yum -y update
yum -y install bzip2 wget gcc gcc-c++ gmp-devel mpfr-devel libmpc-devel
wget https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-8.2.0/gcc-8.2.0.tar.gz
tar zxf gcc-8.2.0.tar.gz
cd gcc-8.2.0
./contrib/download_prerequisites
./configure --disable-multilib --enable-languages=c,c++
make -j$(nproc)
make install 

2. Update libstdc++

Command

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

Output

/usr/local/lib64/libstdc++.so.6
/usr/local/lib64/libstdc++.so.6.0.25
/usr/local/lib64/libstdc++.so.6.0.25-gdb.py
/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/lib64/libstdc++.so.6
/usr/lib64/libstdc++.so.6.0.19
/usr/lib64/libstdc++.so.6.0.25
/root/gcc-8.2.0/prev-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6
/root/gcc-8.2.0/prev-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.25
/root/gcc-8.2.0/stage1-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6
/root/gcc-8.2.0/stage1-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.25
/root/gcc-8.2.0/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6
/root/gcc-8.2.0/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.25

Command

cp /root/gcc-8.2.0/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.25 /lib64
rm -f /lib64/libstdc++.so.6
cd /lib64
ln -s /lib64/libstdc++.so.6.0.25 libstdc++.so.6

3. Installing node-canvas compilation dependencies

yum install gcc-c++ cairo-devel pango-devel libjpeg-turbo-devel giflib-devel

4. Installing node-canvas

npm install canvas
npx node-pre-gyp rebuild -C ./node_modules/canvas

Install canvas:2.8.0 successfully.

mohamadpk commented 3 years ago

1.copy and replace all from/node_modules/canvas/build/Release exclude canvas.node,canvas-postbuild.node,obj.target,.deps to /lib64 2.sudo yum install gcc-c++ cairo-devel pango-devel libjpeg-turbo-devel giflib-devel for me it is done.and work.to all my centos server 7 with canvas 2.8.0

YuriyVorobyov96 commented 2 years ago

@stringang thank you!!! it worked for me

mohamadpk commented 2 years ago

if your os get a problem with all copy .you can copy just libstdc++-6 to /lib64

SilvaQ commented 2 years ago

make -j$(nproc) looping this warning:

/bin/sh ../../libtool --tag CXX --tag disable-shared --mode=compile /DataDisk/demo/gcc-8.2.0/host-x86_64-pc-linux-gnu/gcc/xgcc -shared-libgcc -B/DataDisk/demo/gcc-8.2.0/host-x86_64-pc-linux-gnu/gcc -nostdinc++ -L/DataDisk/demo/gcc-8.2.0/x86_64-pc-linux-gnu/libstdc++-v3/src -L/DataDisk/demo/gcc-8.2.0/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -L/DataDisk/demo/gcc-8.2.0/x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs -B/usr/local/x86_64-pc-linux-gnu/bin/ -B/usr/local/x86_64-pc-linux-gnu/lib/ -isystem /usr/local/x86_64-pc-linux-gnu/include -isystem /usr/local/x86_64-pc-linux-gnu/sys-include -I/DataDisk/demo/gcc-8.2.0/libstdc++-v3/../libgcc -I/DataDisk/demo/gcc-8.2.0/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu -I/DataDisk/demo/gcc-8.2.0/x86_64-pc-linux-gnu/libstdc++-v3/include -I/DataDisk/demo/gcc-8.2.0/libstdc++-v3/libsupc++ -prefer-pic -D_GLIBCXX_SHARED -std=gnu++17 -Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi -fdiagnostics-show-location=once -ffunction-sections -fdata-sections -frandom-seed=ops.lo -g -O2 -D_GNU_SOURCE -c -o ops.lo ../../../.././libstdc++-v3/src/filesystem/ops.cc libtool: compile: /DataDisk/demo/gcc-8.2.0/host-x86_64-pc-linux-gnu/gcc/xgcc -shared-libgcc -B/DataDisk/demo/gcc-8.2.0/host-x86_64-pc-linux-gnu/gcc -nostdinc++ -L/DataDisk/demo/gcc-8.2.0/x86_64-pc-linux-gnu/libstdc++-v3/src -L/DataDisk/demo/gcc-8.2.0/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -L/DataDisk/demo/gcc-8.2.0/x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs -B/usr/local/x86_64-pc-linux-gnu/bin/ -B/usr/local/x86_64-pc-linux-gnu/lib/ -isystem /usr/local/x86_64-pc-linux-gnu/include -isystem /usr/local/x86_64-pc-linux-gnu/sys-include -I/DataDisk/demo/gcc-8.2.0/libstdc++-v3/../libgcc -I/DataDisk/demo/gcc-8.2.0/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu -I/DataDisk/demo/gcc-8.2.0/x86_64-pc-linux-gnu/libstdc++-v3/include -I/DataDisk/demo/gcc-8.2.0/libstdc++-v3/libsupc++ -D_GLIBCXX_SHARED -std=gnu++17 -Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi -fdiagnostics-show-location=once -ffunction-sections -fdata-sections -frandom-seed=ops.lo -g -O2 -D_GNU_SOURCE -c ../../../.././libstdc++-v3/src/filesystem/ops.cc -fPIC -DPIC -D_GLIBCXX_SHARED -o ops.o cc1plus: warning: -Wabi won't warn about anything [-Wabi] cc1plus: note: -Wabi warns about differences from the most up-to-date ABI, which is also used by default cc1plus: note: use e.g. -Wabi=11 to warn about changes from GCC 7

Fooweb commented 2 years ago

In case anyone else is having issues here, this worked for me mostly up until this step:

cp /root/gcc-8.2.0/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.25 /lib64 rm -f /lib64/libstdc++.so.6 ln -s /lib64libstdc++.so.6.0.25 libstdc++.so.6

I did not have a copy of the file in /root so I copied from /usr/...then before creating the symbolic link, cd into /lib64 and finally, in the last command, it's missing a slash.

cp /usr/local/lib64/libstdc++.so.6.0.25 /lib64 rm -f /lib64/libstdc++.so.6 cd /lib64 ln -s /lib64/libstdc++.so.6.0.25 libstdc++.so.6

Then the remainder of the commands worked as indicated.

Now I have another issue where the fonts are not being rendered properly and I think I need to add the fonts to the package but not sure how to do that, can anyone help???

stringang commented 2 years ago

@Fooweb updated with my solution.For font issues, see the git repository example

https://github.com/Automattic/node-canvas/blob/master/examples/font.js

kroawen commented 2 years ago

Error: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found

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

if not found CXXABI_1.3.9,update libstdc++.so.6

download libstdc++.so.6.0.26

copy to /usr/lib64/, and :

cd /usr/lib64/ ln -snf ./libstdc++.so.6.0.26 libstdc++.so.6

Error: /lib64/libc.so.6: version `GLIBC_2.18' not found install GLIBC_2.18:

curl -O http://ftp.gnu.org/gnu/glibc/glibc-2.18.tar.gz tar zxf glibc-2.18.tar.gz cd glibc-2.18/ mkdir build cd build/ ./configure --prefix=/usr make -j2 make install

it works for me

Jayafp commented 2 years ago

Error: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found

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

if not found CXXABI_1.3.9,update libstdc++.so.6

download libstdc++.so.6.0.26

copy to /usr/lib64/, and :

cd /usr/lib64/ ln -snf ./libstdc++.so.6.0.26 libstdc++.so.6

Error: /lib64/libc.so.6: version `GLIBC_2.18' not found install GLIBC_2.18:

curl -O http://ftp.gnu.org/gnu/glibc/glibc-2.18.tar.gz tar zxf glibc-2.18.tar.gz cd glibc-2.18/ mkdir build cd build/ ./configure --prefix=/usr make -j2 make install

it works for me

thanks

cliptik2022 commented 1 year ago

thank you

gelinger777 commented 1 year ago

@kroawen you saved my day :) Thank you

rubixibuc commented 1 year ago

Here's my solution:

  1. Follow the direction here to install dependencies https://github.com/Automattic/node-canvas#compiling
  2. Add this postinstall script to your package.json inside scripts: {} "postinstall": "cd ./node_modules/canvas && ../@mapbox/node-pre-gyp/bin/node-pre-gyp install --build-from-source"
  3. Then run scl enable devtoolset-7 -- npm ci to install

Notes:

v-hung commented 1 year ago

Error: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found

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

if not found CXXABI_1.3.9,update libstdc++.so.6

download libstdc++.so.6.0.26

copy to /usr/lib64/, and :

cd /usr/lib64/ ln -snf ./libstdc++.so.6.0.26 libstdc++.so.6

Error: /lib64/libc.so.6: version `GLIBC_2.18' not found install GLIBC_2.18:

curl -O http://ftp.gnu.org/gnu/glibc/glibc-2.18.tar.gz tar zxf glibc-2.18.tar.gz cd glibc-2.18/ mkdir build cd build/ ./configure --prefix=/usr make -j2 make install

it works for me

thanks, I have to change to ../configure --prefix=/usr

pruteanualex commented 1 year ago

Downgrading to canvas 2.6.1 solves the problem while we don't get it fixed on newest version (2.7.0).

not working

junaid900 commented 1 year ago

i am having issue in make -j$(nproc) make: *** No targets specified and no makefile found. Stop.

lqz1 commented 12 months ago

⨯ Error: The specified procedure could not be found. \?\C:\GitHub\snapid-web\node_modules\canvas\build\Release\canvas.node at Module._extensions..node (node:internal/modules/cjs/loader:1473:18) at Module.load (node:internal/modules/cjs/loader:1207:32) at Module._load (node:internal/modules/cjs/loader:1023:12) at Module.require (node:internal/modules/cjs/loader:1235:19) at mod.require (C:\GitHub\snapid-web\node_modules\next\dist\server\require-hook.js:64:28) at require (node:internal/modules/helpers:176:18) at Object. (C:\GitHub\snapid-web\node_modules\canvas\lib\bindings.js:3:18) at Module._compile (node:internal/modules/cjs/loader:1376:14) at Module._extensions..js (node:internal/modules/cjs/loader:1435:10) at Module.load (node:internal/modules/cjs/loader:1207:32) at Module._load (node:internal/modules/cjs/loader:1023:12) at Module.require (node:internal/modules/cjs/loader:1235:19) at mod.require (C:\GitHub\snapid-web\node_modules\next\dist\server\require-hook.js:64:28) at require (node:internal/modules/helpers:176:18) at Object. (C:\GitHub\snapid-web\node_modules\canvas\lib\canvas.js:9:18) at Module._compile (node:internal/modules/cjs/loader:1376:14) at Module._extensions..js (node:internal/modules/cjs/loader:1435:10) at Module.load (node:internal/modules/cjs/loader:1207:32) at Module._load (node:internal/modules/cjs/loader:1023:12) at Module.require (node:internal/modules/cjs/loader:1235:19) at mod.require (C:\GitHub\snapid-web\node_modules\next\dist\server\require-hook.js:64:28) at require (node:internal/modules/helpers:176:18) at Object. (C:\GitHub\snapid-web\node_modules\canvas\index.js:1:16) at Module._compile (node:internal/modules/cjs/loader:1376:14) at Module._extensions..js (node:internal/modules/cjs/loader:1435:10) at Module.load (node:internal/modules/cjs/loader:1207:32) at Module._load (node:internal/modules/cjs/loader:1023:12) at Module.require (node:internal/modules/cjs/loader:1235:19) at mod.require (C:\GitHub\snapid-web\node_modules\next\dist\server\require-hook.js:64:28) at require (node:internal/modules/helpers:176:18) at Object.canvas (C:\GitHub\snapid-web.next\server\app\api\photo\download\route.js:80:18) at webpack_require (C:\GitHub\snapid-web.next\server\webpack-runtime.js:33:43) at eval (webpack-internal:///(rsc)/./src/app/api/photo/download/route.ts:16:64) at (rsc)/./src/app/api/photo/download/route.ts (C:\GitHub\snapid-web.next\server\app\api\photo\download\route.js:376:1) at webpack_require (C:\GitHub\snapid-web.next\server\webpack-runtime.js:33:43) at eval (webpack-internal:///(rsc)/./node_modules/next/dist/build/webpack/loaders/next-app-loader.js?name=app%2Fapi%2Fphoto%2Fdownload%2Froute&page=%2Fapi%2Fphoto%2Fdownload%2Froute&appPaths=&pagePath=private-next-app-dir%2F api%2Fphoto%2Fdownload%2Froute.ts&appDir=C%3A%5CGitHub%5Csnapid-web%5Csrc%5Capp&pageExtensions=tsx&pageExtensions=ts&pageExtensions=jsx&pageExtensions=js&rootDir=C%3A%5CGitHub%5Csnapid-web&isDev=true&tsconfigPath=tsconfig.json&basePath=&assetPrefix=&nextConfigOutput=&preferredRegion=&middlewareConfig=e30%3D!:14:113) at (rsc)/./node_modules/next/dist/build/webpack/loaders/next-app-loader.js?name=app%2Fapi%2Fphoto%2Fdownload%2Froute&page=%2Fapi%2Fphoto%2Fdownload%2Froute&appPaths=&pagePath=private-next-app-dir%2Fapi%2Fphoto%2Fdownload%2Fr oute.ts&appDir=C%3A%5CGitHub%5Csnapid-web%5Csrc%5Capp&pageExtensions=tsx&pageExtensions=ts&pageExtensions=jsx&pageExtensions=js&rootDir=C%3A%5CGitHub%5Csnapid-web&isDev=true&tsconfigPath=tsconfig.json&basePath=&assetPrefix=&nextConfigOutput=&preferredRegion=&middlewareConfig=e30%3D! (C:\GitHub\snapid-web.next\server\app\api\photo\download\route.js:398:1) at webpack_require (C:\GitHub\snapid-web.next\server\webpack-runtime.js:33:43) at webpack_exec (C:\GitHub\snapid-web.next\server\app\api\photo\download\route.js:496:39) at C:\GitHub\snapid-web.next\server\app\api\photo\download\route.js:497:1188 at __webpack_require__.X (C:\GitHub\snapid-web.next\server\webpack-runtime.js:128:21) at C:\GitHub\snapid-web.next\server\app\api\photo\download\route.js:497:47 at Object. (C:\GitHub\snapid-web.next\server\app\api\photo\download\route.js:500:3) at Module._compile (node:internal/modules/cjs/loader:1376:14) at Module._extensions..js (node:internal/modules/cjs/loader:1435:10) at Module.load (node:internal/modules/cjs/loader:1207:32) at Module._load (node:internal/modules/cjs/loader:1023:12) at Module.require (node:internal/modules/cjs/loader:1235:19) at mod.require (C:\GitHub\snapid-web\node_modules\next\dist\server\require-hook.js:64:28) at require (node:internal/modules/helpers:176:18) { code: 'ERR_DLOPEN_FAILED', page: '/api/photo/download' }

guoapeng commented 11 months ago

./configure --prefix=/usr

Firstly I would like to thank @kroawen for the helpful commands which really can solve the problem on centos 7.x and it seems that there are very small change required as below

tar zxf glibc-2.18.tar.gz => tar -zxf glibc-2.18.tar.gz
./configure --prefix=/usr => ../configure --prefix=/usr 

if above can be verified and updated, that could be perfect.