Using Magick++ in a node.js application on heroku

断了今生、忘了曾经 提交于 2019-12-03 07:56:49

I've made some progress on this:

Use the multi buildpack:

heroku config:set BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-multi.git

So that it can load the apt-buildpack in addition to the nodejs one. List your builpacks in .buildpacks:

https://github.com/ddollar/heroku-buildpack-apt.git
https://github.com/heroku/heroku-buildpack-nodejs.git

Now install libmagick++-dev through apt by listing it in a file called Aptfile.

Now if you include imagemagick-native in your package.json:

"dependencies": {
    "imagemagick-native": "1.7.0"
}

It will start compiling. And although $CPATH is set properly by the APT package, node-gyp somehow doesn't seem to forward it to gcc.

This causes the following error:

remote:        > imagemagick-native@1.7.0 install /tmp/build_720834c3a32b65d69ae603d7c618e20f/node_modules/imagemagick-native
remote:        > node-gyp rebuild
remote:        
remote:        make: Entering directory `/tmp/build_720834c3a32b65d69ae603d7c618e20f/node_modules/imagemagick-native/build'
remote:          CXX(target) Release/obj.target/imagemagick/src/imagemagick.o
remote:        In file included from ../src/imagemagick.cc:9:
remote:        ../src/imagemagick.h:1:22: warning: Magick++.h: No such file or directory

So it doesn't solve the problem yet, but I think it's on the right track. Still trying to figure out what's up with node-gyp.


Update

To workaround that problem fork the nodejs buildpack and add the following lines to the top of bin/compile:

path=`echo "$INCLUDE_PATH" | cut -d : -f 1`
export CXX="`which g++` -I$path/ImageMagick"

Works on cedar-14. For the deprecated cedar you would need to use imagemagick-native v1.22.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!