Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/teddy1565/cpp-addons-note
https://github.com/teddy1565/cpp-addons-note
Last synced: 7 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/teddy1565/cpp-addons-note
- Owner: teddy1565
- Created: 2022-09-20T03:37:09.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-09-26T09:03:19.000Z (over 2 years ago)
- Last Synced: 2024-11-11T03:42:44.754Z (2 months ago)
- Language: C++
- Size: 16.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# C++ addons
## 簡介
There are four different interfaces for a Node.js addons
The raw node.h (C++) which is no interface at all - in this case you will have to deal with different V8/Node.js versions - which is very hard and cumbersome;
The old Node.js Nan (C++) which is still maintained and it allows you to have an uniform C++ API across all Node.js versions - but it requires that your addon is built separately for every Node.js version and does not support worker_threads;
The new napi.h (C) which has an uniform ABI across all versions - meaning that a binary module built for one version will work with all later versions;
The newest Node Addon API (C++) which is a set of C++ classes around napi.h that allows you to use NAPI with C++ semantics. It is fully compatible with napi.h and you can mix the two.
For a new module, Node Addon API is by far the best choice.## 實際操作步驟
```shell
npm install -g node-gyp
#需要撰寫binding.gyp內容
touch binding.gyp# 撰寫後使用node-gyp 初始化設定
node-gyp configure# 寫完後 build
node-gyp build```
## vscode
import path
- windows
- C:\Users\User\AppData\Local\node-gyp\Cache\\{node_version}\include\node