Node-gyp
依赖:
- python
- VS
可以直接管理员运行:
npm install --global --production windows-build-tools
使用:
{
'targets': [
{
'target_name': 'hsfProtocol',
'sources': ['hsf_protocol.cc'],
'cflags': ['-fexceptions', '-Wall', '-D_FILE_OFFSET_BITS=64','-D_LARGEFILE_SOURCE', '-O2'],
'cflags_cc': ['-fexceptions', '-Wall', '-D_FILE_OFFSET_BITS=64','-D_LARGEFILE_SOURCE', '-O2'],
'cflags!': ['-fno-exceptions'],
'cflags!_cc': ['-fno-exceptions'],
'conditions': [
['OS=="mac"', {
'xcode_settings': {
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES'
}
}]
],
'include_dirs': [
'../hsf_protocol/utils',
'../hsf_protocol/objects',
'../hsf_protocol/hessian',
'../hsf_protocol/hsf']
}
]
- node-gyp configure生成工程
- node-gyp build生成二进制文件.node
- 安装bindings
npm install -save bindings
- ok啦
系统位数问题:
- 使用
node-gyp build --arch ia32/x64
选择不同位数 - 调试的时候使用的electron是安装的node的位数
- 打包的位数是打包的时候选择的位数
- 从上到下要保持一致