使用node-gyp构build时无法加载node.js本机插件,但在使用Visual Studio构build时可以使用

我已经为node.js编写了一个本地插件,使用不带node-gyp的MSVC ++对其进行编译,并在节点REPL和应用程序中成功使用它。 我正在使用x64节点并编译一个x64插件。 我试图用node-gyp来构build这个东西。 我已经得到node-gyp来生成一个Visual Studio解决scheme并编译它,但出来的插件不起作用。 我得到的唯一错误是这样的:

Error: The specified procedure could not be found. at Object.Module._extensions..node (module.js:480:11) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:362:17) at require (module.js:378:17) at repl:1:13 at REPLServer.self.eval (repl.js:111:21) at rli.on.e (repl.js:260:20) at REPLServer.self.eval (repl.js:118:5) at Interface.<anonymous> (repl.js:250:12) 

当我运行一个脚本,试图加载插件,我得到这个:

 module.js:480 process.dlopen(filename, module.exports); ^ Error: The specified procedure could not be found. at Object.Module._extensions..node (module.js:480:11) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:362:17) at require (module.js:378:17) at Object.<anonymous> (c:\blah\testheaders.js:1:75) at Module._compile (module.js:449:26) at Object.Module._extensions..js (module.js:467:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) 

我了解到,dlopen与在Linux上加载dynamic库有关,但无法find与节点相关的任何有用的信息(特别是在Windows上)。 这个插件需要一些第三方dll,但是它们在我的path上,再次,当我编译没有node-gyp时,插件工作正常。

我需要做什么来弄清楚如何使这项工作?

原来,问题出在我使用NODE_MODULEmacros。 我有这样的事情:

 NODE_MODULE(SomeAddonName, Init) 

但我binding.gyp有这样的:

 "target_name": "totallyDifferentName", 

事实certificate,binding.gyp中的target_name必须与模块名称(NODE_MODULE的第一个参数)相同。

感谢@TooTallNate帮助我!