nodejs c++ bindinggyp包含自己写的h
可以在 binding.gyp 文件中通过 sources 属性来包含自己写的头文件,具体操作如下:
- 在 binding.gyp 文件中添加 sources 属性,指定自己写的头文件路径,例如:
{
"targets": [
{
"target_name": "myaddon",
"sources": [
"myaddon.cc",
"myheader.h"
]
}
]
}
- 在 C++ 源文件中包含自己写的头文件,例如:
#include "myheader.h"
// C++ 代码
这样就可以在 Node.js 中使用自己写的 C++ 模块了。
原文地址: https://www.cveoy.top/t/topic/fJWB 著作权归作者所有。请勿转载和采集!