NodeJS C/C++扩展之Hello World~

本文介绍了NodeJS的C/C++扩展,它们是通过动态链接的共享对象,用于在Node.js中使用C/C++库。文章详细阐述了实现扩展涉及的组件,如V8、libuv和Node.js的内部库,并提示了如何避免阻塞事件循环。通过一个简单的创建目录、编写源码、使用node-gyp编译以及编写测试脚本的过程,展示了如何编写和使用第一个“Hello World”插件。
摘要由CSDN通过智能技术生成
先看官方文档

Addons

Node.js Addons are dynamically-linked shared objects, written in C or C++, that can be loaded into Node.js using the require() function, and used just as if they were an ordinary Node.js module. They are used primarily to provide an interface between JavaScript running in Node.js and C/C++ libraries.
Node的插件是动态连接到共享对象上的,可以使用C/C++编写,并能够使用require()语法,使用方法类似于其他的npm模块。Node插件主要用于提供一个接口,使得Javascript能够使用到C/C++类库。
At the moment, the method for implementing Addons is rather complicated, involving knowledge of several components and APIs :
目前,实现插件的方法相当复杂,涉及到多种组件和API的知识:
· V8: the C++ library Node.js currently uses to provide the JavaScript implementation. V8 provides the mechanisms for creating objects, calling functions, etc. V8’s API is documented mostly in the v8.h header file (deps/v8/include/v8.h in the Node.js source tree), which is also
  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值