7

I am deploying a node-js app to heroku that requires the npm package imagemagic-native.

I made the buildpack install libmagick++-dev and export the include path:

export INCLUDE_PATH="$BUILD_DIR/.apt/usr/include:$INCLUDE_PATH"
export CPATH="$INCLUDE_PATH"
export CPPPATH="$INCLUDE_PATH"

Upon installing the imagemagic-native package with npm install, node-gyp is invoked to compile it's binaries. However I get this 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

This suggests that gcc doesn't see the header files for libmagick++, because $CCPATH is not available to it.

How can I make npm install add the path to the list of include_dirs that node-gyp uses?

More detail about my use case is here: Using Magick++ in a node.js application on heroku

4

3 回答 3

6

尝试:

设置环境变量 CXX=/path/to/g++ -Ipath/to/include

然后重新启动该过程。如果您使用的是 bash,则由

export CXX="/path/to/g++ -Ipath/to/include"

/path/to/include 是缺少的标头 Magick++.h 所在的位置

如果这不起作用,您可能必须手动设置 CXX 以将 -I 包含在 /tmp/build_720834c3a32b65d69ae603d7c618e20f/node_modules/imagemagick-native/build 的 makefile 中,然后进入该目录并调用 make。

于 2015-02-05T00:29:03.787 回答
5

我花了一些时间试图回答同样的问题。最后,我在这里找到了正确的方法。您需要'include_dirs'~/.node-gyp/x.x.x/common.gypi. 这就是我将 Mac OS 上的包含目录设置为的方式/opt/local/include/(这是所有 macports intalls 所在的位置):

...
['OS=="mac"', {
  'defines': ['_DARWIN_USE_64_BIT_INODE=1'],
  'include_dirs': ['/opt/local/include'],
  'xcode_settings': {
    'ALWAYS_SEARCH_USER_PATHS': 'NO',
...

虽然我不确定它是否适用于 heroku 环境。

于 2015-06-29T10:08:40.973 回答
1

您还可以在项目 binding.gyp 文件中使用“include_dirs”选项。在格式描述页面上阅读有关可用选项的更多信息。

于 2016-09-04T09:24:42.680 回答