nodejs c++ addon

本文档提供了一份详细的指南,介绍了如何为 Node.js 使用 C++ 编写扩展。内容包括必要的编译器、工具推荐(如 node-gyp)、构建命令、示例资源链接及必要的配置文件说明。

编译器是C++的编译器(g++?)。官方例子:

http://nodejs.org/api/addons.html


民间例子:

http://cnodejs.org/topic/4f3dc5e19605c56a4b05351f


V8 API文档,写C/C++拓展必备

这个API的node版本较老, 是10.X的。

http://izs.me/v8-docs/annotated.html


node-webkit 0.10.2基于node 0.11.13

只有官方文档

http://nodejs.org/docs/v0.11.13/api/addons.html#addons_hello_world


Addon Build工具

建议使用node-gyp,安装方式:npm install -g node-gyp

建议不要用node-waf。

Build CMD: node-gyp configure build 或者 node-gyp rebuild

例子总结

https://github.com/rvagg/node-addon-examples/tree/master/1_hello_world

Github上有Samples。

  1. 需要有binging.gyp告诉node-gyp build的源和目标文件。

格式:

{

  "targets": [

    {

      "target_name": "pidof",

      "sources": [ "pidof.cc" ]

    }

  ]

}

  1. 源文件

C++源文件。

  1. 包信息文件

记录包信息。

转载于:https://my.oschina.net/u/862582/blog/345286

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值