node-gyp在子文件夹

时间:2018-09-10 19:36:38

标签: c++ node.js node-gyp node-addon

我正在尝试制作节点插件,但由于出现以下错误,似乎无法构建,因此出现了问题:

  

无法打开包含文件:“ MagickCore / magick-config.h”:没有此类文件或目录

我的目录结构如下:

ImageMagick
  Magick++
    lib
      Magick++.cpp
      Magick++.h
  MagickCore
    magick-config.h
binding.gyp
imagemagick.cc

我的 binding.gyp 看起来像这样:

{
    'targets': [
        {
            'target_name': 'imagemagick',
            'sources': ['imagemagick.cc'],
            'include_dirs': [
                'ImageMagick/Magick++/lib',
                'ImageMagick/MagickCore',
            ]
        }
    ]
}

和我的 imagemagick.cc 如下:

#include <node.h>
#include <v8.h>
#include <Magick++.h>

namespace demo
{

using v8::FunctionCallbackInfo;
using v8::Isolate;
using v8::Local;
using v8::Object;
using v8::String;
using v8::Value;

void Method(const FunctionCallbackInfo<Value> &args)
{
  Isolate *isolate = args.GetIsolate();
  new Magick::Image();
}

void Initialize(Local<Object> exports)
{
  NODE_SET_METHOD(exports, "resize", Method);
}

NODE_MODULE(NODE_GYP_MODULE_NAME, Initialize)

}

是什么原因导致此问题?

此外,我正在使用vscode,设置如下所示:

{
  "configurations": [
    {
      "name": "Win32",
      "includePath": [
        "${workspaceFolder}/ImageMagick/Magick++/**",
        "${workspaceFolder}/ImageMagick/MagickCore/**",
        "C:\\Users\\rnaddy\\.node-gyp\\10.0.0\\include\\node\\**"
      ],
      "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE"
      ],
      "windowsSdkVersion": "10.0.14393.0",
      "compilerPath": "C:\\mingw-w64\\bin\\gcc.exe",
      "intelliSenseMode": "clang-x64",
      "browse": {
        "path": [
          "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true,
        "databaseFilename": ""
      }
    }
  ],
  "version": 4
}

0 个答案:

没有答案