7

第28课:用 C++ 开发 Node.js 和 Electron 本地模块

 4 years ago
source link: https://blog.csdn.net/nokiaguy/article/details/108729626
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

开发前的准备工作

在开发本地模块之前,需要先安装必要的软件,如编译器、各种工具等。

  • Windows:Visual Studio 2017
  • Mac OS X:Clang,安装 XCode 就可以

node-gyp 是 Node.js 下的 C++ 扩展构建工具,用 Python 编写(必须是 Python 2.7,建议安装 anaconda 环境),是基于 GYP 来进行工作的(Generate Your Projects),Google 出品的一套构建工具,通过一个 *.gyp 文件生成不同系统所需要的项目文件,(如 Makefile、Visual Studio 项目文件等)以供构建和编译。

需要创建一个 binding.gyp 文件,并进行配置。

使用 node-gyp 的条件:

  • Python 2.7
  • GCC(tdm-gcc-5.1.0-3)

使用 Anaconda 切换到 Python 2.7 后的效果如下图所示。

1240

安装 nody-gyp:

npm install -g node-gyp

查看 node-gyp 命令:

node-gyp -h

Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK