C&C++   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了c – 使用node-gyp构建时无法加载node.js本机插件,但在使用Visual Studio构建时可以正常工作大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_801_0@
我为node.js编写了一个本机插件,使用没有node-gyp的MSVC编译它,并在节点REPL和应用程序中成功使用它.我正在使用X64节点并编译x64插件.我正试图用node-gyp来构建东西.我已经获得了node-gyp来@L_674_3@Visual studio解决方案并对其进行编译,但是出来的插件不起作用.我得到的唯一错误是:
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)

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

@H_531_2@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上加载动态库有关,但找不到与节点相关的任何有用信息(特别是在Windows上).这个插件需要一些第三方dll,但是它们在我的路径上,而且当我在没有node-gyp的情况下编译时,插件工作正常.

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

解决方法

事实证明,问题在于我使用了NODE_MODULE宏.我有这样的事情:
NODE_MODULE(SomeAddonName,Init)

但是我的binding.gyp有这个:

"target_name": "@R_890_10586@llyDifferentName",

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

感谢@TooTallNate帮助我做到这一点!

大佬总结

以上是大佬教程为你收集整理的c – 使用node-gyp构建时无法加载node.js本机插件,但在使用Visual Studio构建时可以正常工作全部内容,希望文章能够帮你解决c – 使用node-gyp构建时无法加载node.js本机插件,但在使用Visual Studio构建时可以正常工作所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。