微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何为电子构建节点原生模块

如何解决如何为电子构建节点原生模块

我需要使用 node-gyp 重建 aws-crt,以便它可以在 windows 上与电子一起使用。

我已经分叉了这个 repo https://github.com/zhex900/aws-crt-nodejs添加binding.gyp

node-gyp build 有效

但我无法使用电子标题

这些是错误

PS C:\Code\aws-crt-nodejs> node-gyp rebuild --target=13.1.2 --arch=x64 --dist-url=https://electronjs.org/headers
gyp info it worked if it ends with ok
gyp info using node-gyp@8.1.0
gyp info using node@14.17.0 | win32 | x64
gyp info find Python using Python version 3.7.9 found at "C:\Users\jake\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\python.exe"
gyp info find VS using VS2019 (16.10.31402.337) found at:
gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community"
gyp info find VS run with --verbose for detailed information
gyp info spawn C:\Users\jake\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\python.exe
gyp info spawn args [
gyp info spawn args   'C:\\Users\\jake\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',gyp info spawn args   'binding.gyp',gyp info spawn args   '-f',gyp info spawn args   'msvs',gyp info spawn args   '-I',gyp info spawn args   'C:\\Code\\aws-crt-nodejs\\build\\config.gypi',gyp info spawn args   'C:\\Users\\jake\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\addon.gypi',gyp info spawn args   'C:\\Users\\jake\\AppData\\Local\\node-gyp\\Cache\\13.1.2\\include\\node\\common.gypi',gyp info spawn args   '-Dlibrary=shared_library',gyp info spawn args   '-Dvisibility=default',gyp info spawn args   '-Dnode_root_dir=C:\\Users\\jake\\AppData\\Local\\node-gyp\\Cache\\13.1.2',gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\jake\\AppData\\Roaming\\npm\\node_modules\\node-gyp',gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\jake\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\13.1.2\\\\<(target_arch)\\\\node.lib',gyp info spawn args   '-Dmodule_root_dir=C:\\Code\\aws-crt-nodejs',gyp info spawn args   '-Dnode_engine=v8',gyp info spawn args   '--depth=.',gyp info spawn args   '--no-parallel',gyp info spawn args   '--generator-output',gyp info spawn args   'C:\\Code\\aws-crt-nodejs\\build',gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe
gyp info spawn args [
gyp info spawn args   'build/binding.sln',gyp info spawn args   '/clp:Verbosity=minimal',gyp info spawn args   '/nologo',gyp info spawn args   '/p:Configuration=Release;Platform=x64'
gyp info spawn args ]
Building the projects in this solution one at a time. To enable parallel build,please add the "-m" switch.
  auth.c
C:\Code\aws-crt-nodejs\source\module.h(13,1): warning C4005: 'NAPI_VERSION': macro redeFinition [C:\Code\aws-crt-nodejs
\build\aws-crt.vcxproj]
C:\Code\aws-crt-nodejs\source\auth.c : message : see prevIoUs deFinition of 'NAPI_VERSION' [C:\Code\aws-crt-nodejs\buil
d\aws-crt.vcxproj]
  class_binder.c
C:\Code\aws-crt-nodejs\source\module.h(13,1): warning C4005: 'NAPI_VERSION': macro redeFinition [C:\Code\aws-crt-nodejs
\build\aws-crt.vcxproj]
C:\Code\aws-crt-nodejs\source\class_binder.c : message : see prevIoUs deFinition of 'NAPI_VERSION' [C:\Code\aws-crt-nod
ejs\build\aws-crt.vcxproj]
  crypto.c
C:\Code\aws-crt-nodejs\source\module.h(13,1): warning C4005: 'NAPI_VERSION': macro redeFinition [C:\Code\aws-crt-nodejs
\build\aws-crt.vcxproj]
C:\Code\aws-crt-nodejs\source\crypto.c : message : see prevIoUs deFinition of 'NAPI_VERSION' [C:\Code\aws-crt-nodejs\bu
ild\aws-crt.vcxproj]
  http_connection.c
C:\Code\aws-crt-nodejs\source\module.h(13,1): warning C4005: 'NAPI_VERSION': macro redeFinition [C:\Code\aws-crt-nodejs
\build\aws-crt.vcxproj]
C:\Code\aws-crt-nodejs\source\http_connection.c : message : see prevIoUs deFinition of 'NAPI_VERSION' [C:\Code\aws-crt-
nodejs\build\aws-crt.vcxproj]
  http_connection_manager.c
C:\Code\aws-crt-nodejs\source\module.h(13,1): warning C4005: 'NAPI_VERSION': macro redeFinition [C:\Code\aws-crt-nodejs
\build\aws-crt.vcxproj]
C:\Code\aws-crt-nodejs\source\http_connection_manager.c : message : see prevIoUs deFinition of 'NAPI_VERSION' [C:\Code\
aws-crt-nodejs\build\aws-crt.vcxproj]
  http_headers.c
C:\Code\aws-crt-nodejs\source\module.h(13,1): warning C4005: 'NAPI_VERSION': macro redeFinition [C:\Code\aws-crt-nodejs
\build\aws-crt.vcxproj]
C:\Code\aws-crt-nodejs\source\http_headers.c : message : see prevIoUs deFinition of 'NAPI_VERSION' [C:\Code\aws-crt-nod
ejs\build\aws-crt.vcxproj]
  http_message.c
C:\Code\aws-crt-nodejs\source\module.h(13,1): warning C4005: 'NAPI_VERSION': macro redeFinition [C:\Code\aws-crt-nodejs
\build\aws-crt.vcxproj]
C:\Code\aws-crt-nodejs\source\http_message.c : message : see prevIoUs deFinition of 'NAPI_VERSION' [C:\Code\aws-crt-nod
ejs\build\aws-crt.vcxproj]
  http_stream.c
C:\Code\aws-crt-nodejs\source\module.h(13,1): warning C4005: 'NAPI_VERSION': macro redeFinition [C:\Code\aws-crt-nodejs
\build\aws-crt.vcxproj]
C:\Code\aws-crt-nodejs\source\http_stream.c : message : see prevIoUs deFinition of 'NAPI_VERSION' [C:\Code\aws-crt-node
js\build\aws-crt.vcxproj]
  io.c
C:\Code\aws-crt-nodejs\source\module.h(13,1): warning C4005: 'NAPI_VERSION': macro redeFinition [C:\Code\aws-crt-nodejs
\build\aws-crt.vcxproj]
C:\Code\aws-crt-nodejs\source\io.c : message : see prevIoUs deFinition of 'NAPI_VERSION' [C:\Code\aws-crt-nodejs\build\
aws-crt.vcxproj]
  logger.c
C:\Code\aws-crt-nodejs\source\module.h(13,1): warning C4005: 'NAPI_VERSION': macro redeFinition [C:\Code\aws-crt-nodejs
\build\aws-crt.vcxproj]
C:\Code\aws-crt-nodejs\source\logger.c : message : see prevIoUs deFinition of 'NAPI_VERSION' [C:\Code\aws-crt-nodejs\bu
ild\aws-crt.vcxproj]
  module.c
C:\Code\aws-crt-nodejs\source\module.h(13,1): warning C4005: 'NAPI_VERSION': macro redeFinition [C:\Code\aws-crt-nodejs
\build\aws-crt.vcxproj]
C:\Code\aws-crt-nodejs\source\module.c : message : see prevIoUs deFinition of 'NAPI_VERSION' [C:\Code\aws-crt-nodejs\bu
ild\aws-crt.vcxproj]
C:\Code\aws-crt-nodejs\source\module.c(543,18): warning C4229: anachronism used: modifiers on data are ignored [C:\Code
\aws-crt-nodejs\build\aws-crt.vcxproj]
C:\Code\aws-crt-nodejs\source\module.c(543,18): error C2143: Syntax error: missing '{' before '-' [C:\Code\aws-crt-node
js\build\aws-crt.vcxproj]
C:\Code\aws-crt-nodejs\source\module.c(543,18): error C2059: Syntax error: '-' [C:\Code\aws-crt-nodejs\build\aws-crt.vc
xproj]
C:\Code\aws-crt-nodejs\source\module.c(543,18): error C2143: Syntax error: missing ')' before '-' [C:\Code\aws-crt-node
js\build\aws-crt.vcxproj]
C:\Code\aws-crt-nodejs\source\module.c(543,18): error C2165: 'left-side modifier': cannot modify pointers to data [C:\C
ode\aws-crt-nodejs\build\aws-crt.vcxproj]
C:\Code\aws-crt-nodejs\source\module.c(543,18): error C2059: Syntax error: ')' [C:\Code\aws-crt-nodejs\build\aws-crt.vc
xproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe` Failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\jake\AppData\Roaming\npm\node_modules\node-gyp\lib\build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:376:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
gyp ERR! System Windows_NT 10.0.19043
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\jake\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--target=13.1.2" "--arch=x64" "--dist-url=https://electronjs.org/headers"
gyp ERR! cwd C:\Code\aws-crt-nodejs
gyp ERR! node -v v14.17.0
gyp ERR! node-gyp -v v8.1.0
gyp ERR! not ok

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。