Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPM install fails while compiling CanvasRenderingContext2d.o #1257

Closed
david-jimenez-sp opened this issue Sep 26, 2018 · 12 comments
Closed

NPM install fails while compiling CanvasRenderingContext2d.o #1257

david-jimenez-sp opened this issue Sep 26, 2018 · 12 comments
Labels

Comments

@david-jimenez-sp
Copy link

Issue

npm install fails on a Mac OS High Sierra. The binary is not found and it falls back to compiling. Compilation fails while making CanvasRenderingContext2d.o

Davids-MacBook-Pro:install david$ npm install canvas

> canvas@2.0.0-alpha.13 install /Users/david/install/node_modules/canvas
> node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download(404): https://github.com/node-gfx/node-canvas-prebuilt/releases/download/v2.0.0-alpha.13/canvas-prebuilt-v2.0.0-alpha.13-node-v48-darwin-unknown-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for canvas@2.0.0-alpha.13 and node@6.14.4 (node-v48 ABI, unknown) (falling back to source compile with node-gyp)
  SOLINK_MODULE(target) Release/canvas-postbuild.node
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
  CXX(target) Release/obj.target/canvas/src/backend/Backend.o
  CXX(target) Release/obj.target/canvas/src/backend/ImageBackend.o
  CXX(target) Release/obj.target/canvas/src/backend/PdfBackend.o
  CXX(target) Release/obj.target/canvas/src/backend/SvgBackend.o
  CXX(target) Release/obj.target/canvas/src/Backends.o
  CXX(target) Release/obj.target/canvas/src/Canvas.o
  CXX(target) Release/obj.target/canvas/src/CanvasGradient.o
  CXX(target) Release/obj.target/canvas/src/CanvasPattern.o
  CXX(target) Release/obj.target/canvas/src/CanvasRenderingContext2d.o
../src/CanvasRenderingContext2d.cc:1380:49: error: no matching constructor for initialization of 'const std::map<std::string, cairo_operator_t>'
      (aka 'const map<basic_string<char>, _cairo_operator>')
  const std::map<std::string, cairo_operator_t> blendmodes = {
                                                ^            ~
/usr/include/c++/4.2.1/bits/stl_map.h:188:9: note: candidate constructor template not viable: requires 2 arguments, but 30 were provided
        map(_InputIterator __first, _InputIterator __last)
        ^
/usr/include/c++/4.2.1/bits/stl_map.h:204:9: note: candidate constructor template not viable: requires at most 4 arguments, but 30 were provided
        map(_InputIterator __first, _InputIterator __last,
        ^
/usr/include/c++/4.2.1/bits/stl_map.h:165:7: note: candidate constructor not viable: requires at most 2 arguments, but 30 were provided
      map(const _Compare& __comp, const allocator_type& __a = allocator_type())
      ^
/usr/include/c++/4.2.1/bits/stl_map.h:175:7: note: candidate constructor not viable: requires single argument '__x', but 30 arguments were provided
      map(const map& __x)
      ^
/usr/include/c++/4.2.1/bits/stl_map.h:157:7: note: candidate constructor not viable: requires 0 arguments, but 30 were provided
      map()
      ^
1 error generated.
make: *** [Release/obj.target/canvas/src/CanvasRenderingContext2d.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/Cellar/node@6/6.14.4/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:219:12)
gyp ERR! System Darwin 17.7.0
gyp ERR! command "/usr/local/Cellar/node@6/6.14.4/bin/node" "/usr/local/Cellar/node@6/6.14.4/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/david/install/node_modules/canvas/build/Release/canvas-prebuilt.node" "--module_name=canvas-prebuilt" "--module_path=/Users/david/install/node_modules/canvas/build/Release" "--napi_version=3" "--node_abi_napi=napi"
gyp ERR! cwd /Users/david/install/node_modules/canvas
gyp ERR! node -v v6.14.4
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/Cellar/node@6/6.14.4/bin/node /usr/local/Cellar/node@6/6.14.4/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/david/install/node_modules/canvas/build/Release/canvas-prebuilt.node --module_name=canvas-prebuilt --module_path=/Users/david/install/node_modules/canvas/build/Release --napi_version=3 --node_abi_napi=napi' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/david/install/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:106:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:920:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:230:5)
node-pre-gyp ERR! System Darwin 17.7.0
node-pre-gyp ERR! command "/usr/local/Cellar/node@6/6.14.4/bin/node" "/Users/david/install/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/david/install/node_modules/canvas
node-pre-gyp ERR! node -v v6.14.4
node-pre-gyp ERR! node-pre-gyp -v v0.9.1
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/Cellar/node@6/6.14.4/bin/node /usr/local/Cellar/node@6/6.14.4/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/david/install/node_modules/canvas/build/Release/canvas-prebuilt.node --module_name=canvas-prebuilt --module_path=/Users/david/install/node_modules/canvas/build/Release --napi_version=3 --node_abi_napi=napi' (1)
npm WARN enoent ENOENT: no such file or directory, open '/Users/david/install/package.json'
npm WARN install No description
npm WARN install No repository field.
npm WARN install No README data
npm WARN install No license field.
npm ERR! Darwin 17.7.0
npm ERR! argv "/usr/local/Cellar/node@6/6.14.4/bin/node" "/usr/local/opt/node@6/bin/npm" "install" "canvas"
npm ERR! node v6.14.4
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE

npm ERR! canvas@2.0.0-alpha.13 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1

Steps to Reproduce

Using brew

  1. brew install pkg-config cairo pango libpng jpeg giflib
  2. npm install cairo

Your Environment

  • canvas@2.0.0-alpha.13
  • node 6.14.4, npm 3.10.10 on Mac OS X 10.13.6 using Xcode 10.0
@david-jimenez-sp
Copy link
Author

btw if some can upload a prebuilt version, it would be awesome.

@zbjornson
Copy link
Collaborator

I'm not a mac person and can't give too much helpful info, but that means your compiler is old. You need at least C++11 support. Hopefully that steers you in the right direction...

@LinusU
Copy link
Collaborator

LinusU commented Sep 26, 2018

Hmmm, Xcode 10 should have full support for C++11 though 🤔

@zbjornson
Copy link
Collaborator

include/c++/4.2.1 -- is that the current version, or did it pick the wrong version somehow? Hard to google that but I see some results indicating that that goes with Apple LLVM 8.

@LinusU
Copy link
Collaborator

LinusU commented Sep 26, 2018

Hmm, strange, I don't even have /usr/include on my computer 🤔 (macOS 10.14, Xcode 10)

@LinusU
Copy link
Collaborator

LinusU commented Sep 26, 2018

@david-jimenez-sp do you have GCC installed via Homebrew?

@david-jimenez-sp
Copy link
Author

I do not. For reference I have these installed with Homebrew. I'm not sure if that is a side effect of another library installed with Homebrew.

david$ brew list
boost
cairo
eigen
elasticsearch@5.6
erlang
ffmpeg
fontconfig
freetype
fribidi
gdbm
gettext
ghostscript
giflib
glib
graphicsmagick
graphite2
harfbuzz
icu4c
ilmbase
imagemagick@6
jasper
jpeg
lame
libffi
libpng
libtiff
libtool
little-cms2
mongodb@3.4
mongoose
nginx
node@6
numpy
opencv
openexr
openssl
pango
pcre
pixman
pkg-config
python
python@2
rabbitmq
readline
redis
s3cmd
sqlite
tbb
wxmac
x264
xvid
xz

@StoneJT
Copy link

StoneJT commented Sep 28, 2018

Had this happen to me today, so I decided to spend some time investigating. The common.gypi currently included with Node.js 6.x doesn't explicitly set CLANG_CXX_LIBRARY to "libc++", which causes Clang to default to a non-C++11 standard library (due to MACOSX_DEPLOYMENT_TARGET being set to "10.7", also in common.gypi). From Node.js 7.0.0 onwards, CLANG_CXX_LIBRARY is set accordingly, so this issue should be limited to Node.js 6.x on Mac OS.

@david-jimenez-sp - If you try running npm install with the -d flag, you should be able to see where node-gyp is loading common.gypi from - hopefully it'll be in .node-gyp in your home directory. If it is, you should be able to patch it as below:

# Assumes that you're in the directory where common.gypi.diff.txt is saved,
# and node is a 6.x version
patch "${HOME}/.node-gyp/$(node -v | cut -c2-)/include/node/common.gypi" common.gypi.diff.txt

common.gypi.diff.txt

If that fixes it for @david-jimenez-sp , then the easiest solution would probably be to specify CLANG_CXX_LIBRARY under xcode_settings in binding.gyp.

@david-jimenez-sp
Copy link
Author

That did the trick. Thanks @StoneJT for figuring this out!

@zbjornson
Copy link
Collaborator

Nice work. Happy to accept a PR for that if anyone wants!

@alatras
Copy link

alatras commented Dec 5, 2018

@StoneJT Thank you!

@zbjornson
Copy link
Collaborator

Closing since this only affected Node.js v6.x, which node-canvas no longer supports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants