Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js本机扩展示例_Node.js_Native - Fatal编程技术网

Node.js本机扩展示例

Node.js本机扩展示例,node.js,native,Node.js,Native,我无法运行Node.js本机扩展的最简单类型,Hello World,我不知道为什么 我在这里使用的示例是: node gyp运行正常,但当我尝试在node中要求它时,我得到一个错误: Error: invalid argument at Object..node (module.js:472:11) at Module.load (module.js:348:31) at Function._load (module.js:308:12) at Module.r

我无法运行Node.js本机扩展的最简单类型,Hello World,我不知道为什么

我在这里使用的示例是:

node gyp
运行正常,但当我尝试在node中要求它时,我得到一个错误:

Error: invalid argument at Object..node (module.js:472:11) at Module.load (module.js:348:31) at Function._load (module.js:308:12) at Module.require (module.js:354:17) at require (module.js:370:17) at repl:1:13 at REPLServer.eval (repl.js:80:21) at repl.js:190:20 at REPLServer.eval (repl.js:87:5) at Interface. (repl.js:182:12) 错误:参数无效 在Object..node(module.js:472:11) 在Module.load(Module.js:348:31) at功能。加载(module.js:308:12) at Module.require(Module.js:354:17) 根据需要(模块js:370:17) 回复:1:13 在REPLServer.eval(repl.js:80:21) 回复js:190:20 在REPLServer.eval(repl.js:87:5) 在接口处。(回复js:182:12)
这是什么,以及在使用本机扩展时如何调试此类错误?

显然,在我将
init
部分包装到
extern“C”
块中之后,该示例现在可以运行了


现在一切都很好。

显然,在我将
init
部分包装到
extern“C”
块中之后,该示例现在可以工作了


现在一切都好了。

此外,如果您碰巧遵循以下示例:

请记住,您赋予节点模块的初始化功能不能是静态的!Node.js用于注册模块的内省库或其他机制似乎不支持读取C中的静态函数(名称)


希望这能帮助每个有类似问题的人

此外,如果您碰巧遵循此示例:

请记住,您赋予节点模块的初始化功能不能是静态的!Node.js用于注册模块的内省库或其他机制似乎不支持读取C中的静态函数(名称)

希望这能帮助每个有类似问题的人

自述文件中解释了所有内容。


自述文件中解释了所有内容。

代码在我上面链接的示例中。如果它没有编译,那么要么是我的系统设置不正确,要么是我做了一些非常错误的事情。如果它没有编译,那么要么是我的系统设置不正确,要么是我做错了什么。