无法在Windows 10上使用ffi运行电子重建(src \ ffi.cc(228):错误C2065:'句柄':未声明的标识符)

时间:2019-07-03 11:28:12

标签: electron ffi electron-rebuild

我需要在节点电子项目中使用模块“ ffi”。我可以使用“ gyp”来重建它并使用节点中的库,但是不能使用“ electron-rebuild”来重建它并在电子中使用它。

我已经跑步:

cd ./node_modules/.bin && electron-rebuild --force --module-dir=../../

它给了我以下错误。 (由于它超出了堆栈溢出的字符数限制,我已删除了一些警告。整个日志位于:https://github.com/electron/electron-rebuild/issues/308

> cd ./node_modules/.bin && electron-rebuild --force --module-dir=../../

× Rebuild Failed

An unhandled error occurred inside electron-rebuild
�ڴ˽��������һ������һ����Ŀ����Ҫ���ò������ɣ�����ӡ�/m�����ء�
  Building assembly file ..\..\..\deps\libffi\src\x86\win64.asm
   Assembling: ..\..\..\deps\libffi\src\x86\win64.asm
  prep_cif.c
  types.c
  raw_api.c
  java_raw_api.c
  closures.c
  ffi.c
  win_delay_load_hook.cc
  ffi.vcxproj -> D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\Release\\libffi.lib
  ffi.cc
  callback_info.cc
  threaded_callback_invokation.cc
  win32-dlfcn.cc
  c:\users\tinynight\.electron-gyp\5.0.6\include\node\v8.h(2389): note: see declaration of 'v8::Value::ToBoolean' (compiling source file ..\src\callback_info.cc)c:\users\tinynight\.electron-gyp\5.0.6\include\node\v8.h(2389): note: see declaration of 'v8::Value::ToBoolean' (compiling source file ..\src\threaded_callback_invokation.cc)

  win_delay_load_hook.cc
..\src\callback_info.cc(208): error C2065: 'Handle': undeclared identifier [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
  d:\study\roboterra\desktop\frontend\electron\node_modules\nan\nan_maybe_43_inl.h(117): note: see declaration of 'Nan::ForceSet'
..\src\callback_info.cc(208): error C2275: 'v8::Object': illegal use of this type as an expression..\src\ffi.cc(63): warning C4996: 'Nan::ForceSet': was declared deprecated [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]

  c:\users\tinynight\.electron-gyp\5.0.6\include\node\v8.h(3257): note: see declaration of 'v8::Object'd:\study\roboterra\desktop\frontend\electron\node_modules\nan\nan_maybe_43_inl.h(117): note: see declaration of 'Nan::ForceSet'

..\src\callback_info.cc(208): error C2065: 'target': undeclared identifier [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
..\src\ffi.cc(64): warning C4996: 'Nan::ForceSet': was declared deprecated..\src\callback_info.cc(208): error C2761: 'void CallbackInfo::Initialize(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)': member function redeclaration not allowed [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]

  d:\study\roboterra\desktop\frontend\electron\node_modules\nan\nan_maybe_43_inl.h(117): note: see declaration of 'Nan::ForceSet'
..\src\callback_info.cc(208): error C2448: 'CallbackInfo::Initialize': function-style initializer appears to be a function definition [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
..\src\ffi.cc(184): error C2065: 'Handle': undeclared identifier [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
..\src\ffi.cc(184): error C2275: 'v8::Value': illegal use of this type as an expression [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
  c:\users\tinynight\.electron-gyp\5.0.6\include\node\v8.h(2104): note: see declaration of 'v8::Value'
..\src\ffi.cc(184): error C2065: 'cif_buf': undeclared identifier [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
..\src\ffi.cc(185): error C2065: 'cif_buf': undeclared identifier [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
..\src\ffi.cc(189): error C2065: 'cif_buf': undeclared identifier [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
..\src\ffi.cc(189): error C2228: left of '.As' must have class/struct/union [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
  ..\src\ffi.cc(189): note: type is 'unknown-type'
..\src\ffi.cc(189): error C2059: syntax error: ')' [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
..\src\ffi.cc(228): error C2065: 'Handle': undeclared identifier [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
..\src\ffi.cc(228): error C2275: 'v8::Value': illegal use of this type as an expression [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
  c:\users\tinynight\.electron-gyp\5.0.6\include\node\v8.h(2104): note: see declaration of 'v8::Value'
..\src\ffi.cc(228): error C2065: 'cif_buf': undeclared identifier [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
..\src\ffi.cc(229): error C2065: 'cif_buf': undeclared identifier [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
..\src\ffi.cc(233): error C2065: 'cif_buf': undeclared identifier [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
..\src\ffi.cc(233): error C2228: left of '.As' must have class/struct/union [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
  ..\src\ffi.cc(233): note: type is 'unknown-type'
..\src\ffi.cc(233): error C2059: syntax error: ')' [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (D:\study\RoboTerra\desktop\frontend\electron\node_modules\node-gyp\lib\build.js:262:23)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Windows_NT 10.0.15063
gyp ERR! command "D:\\ToolsF\\nodeJS\\node.exe" "D:\\study\\RoboTerra\\desktop\\frontend\\electron\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--target=5.0.6" "--arch=x64" "--dist-url=https://electronjs.org/headers" "--build-from-source" "--msvs_version=2015"
gyp ERR! cwd D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi
gyp ERR! node -v v8.10.0
gyp ERR! node-gyp -v v4.0.0
gyp ERR! not ok

Failed with exit code: 1

Error: �ڴ˽��������һ������һ����Ŀ����Ҫ���ò������ɣ�����ӡ�/m�����ء�
  Building assembly file ..\..\..\deps\libffi\src\x86\win64.asm
   Assembling: ..\..\..\deps\libffi\src\x86\win64.asm
  prep_cif.c
  types.c
  raw_api.c
  java_raw_api.c
  closures.c
  ffi.c
  win_delay_load_hook.cc
  ffi.vcxproj -> D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\Release\\libffi.lib
  ffi.cc
  callback_info.cc
  threaded_callback_invokation.cc
  win32-dlfcn.cc

  win_delay_load_hook.cc
..\src\callback_info.cc(208): error C2065: 'Handle': undeclared identifier [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
  d:\study\roboterra\desktop\frontend\electron\node_modules\nan\nan_maybe_43_inl.h(117): note: see declaration of 'Nan::ForceSet'
..\src\callback_info.cc(208): error C2275: 'v8::Object': illegal use of this type as an expression..\src\ffi.cc(63): warning C4996: 'Nan::ForceSet': was declared deprecated [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]

  c:\users\tinynight\.electron-gyp\5.0.6\include\node\v8.h(3257): note: see declaration of 'v8::Object'd:\study\roboterra\desktop\frontend\electron\node_modules\nan\nan_maybe_43_inl.h(117): note: see declaration of 'Nan::ForceSet'

..\src\callback_info.cc(208): error C2065: 'target': undeclared identifier [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
..\src\ffi.cc(64): warning C4996: 'Nan::ForceSet': was declared deprecated..\src\callback_info.cc(208): error C2761: 'void CallbackInfo::Initialize(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)': member function redeclaration not allowed [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]

  d:\study\roboterra\desktop\frontend\electron\node_modules\nan\nan_maybe_43_inl.h(117): note: see declaration of 'Nan::ForceSet'
..\src\callback_info.cc(208): error C2448: 'CallbackInfo::Initialize': function-style initializer appears to be a function definition [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
..\src\ffi.cc(184): error C2065: 'Handle': undeclared identifier [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
..\src\ffi.cc(184): error C2275: 'v8::Value': illegal use of this type as an expression [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
  c:\users\tinynight\.electron-gyp\5.0.6\include\node\v8.h(2104): note: see declaration of 'v8::Value'
..\src\ffi.cc(184): error C2065: 'cif_buf': undeclared identifier [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
..\src\ffi.cc(185): error C2065: 'cif_buf': undeclared identifier [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
..\src\ffi.cc(189): error C2065: 'cif_buf': undeclared identifier [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
..\src\ffi.cc(189): error C2228: left of '.As' must have class/struct/union [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
  ..\src\ffi.cc(189): note: type is 'unknown-type'
..\src\ffi.cc(189): error C2059: syntax error: ')' [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
..\src\ffi.cc(228): error C2065: 'Handle': undeclared identifier [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
..\src\ffi.cc(228): error C2275: 'v8::Value': illegal use of this type as an expression [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
  c:\users\tinynight\.electron-gyp\5.0.6\include\node\v8.h(2104): note: see declaration of 'v8::Value'
..\src\ffi.cc(228): error C2065: 'cif_buf': undeclared identifier [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
..\src\ffi.cc(229): error C2065: 'cif_buf': undeclared identifier [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
..\src\ffi.cc(233): error C2065: 'cif_buf': undeclared identifier [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
..\src\ffi.cc(233): error C2228: left of '.As' must have class/struct/union [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
  ..\src\ffi.cc(233): note: type is 'unknown-type'
..\src\ffi.cc(233): error C2059: syntax error: ')' [D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi\build\ffi_bindings.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (D:\study\RoboTerra\desktop\frontend\electron\node_modules\node-gyp\lib\build.js:262:23)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Windows_NT 10.0.15063
gyp ERR! command "D:\\ToolsF\\nodeJS\\node.exe" "D:\\study\\RoboTerra\\desktop\\frontend\\electron\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--target=5.0.6" "--arch=x64" "--dist-url=https://electronjs.org/headers" "--build-from-source" "--msvs_version=2015"
gyp ERR! cwd D:\study\RoboTerra\desktop\frontend\electron\node_modules\ffi
gyp ERR! node -v v8.10.0
gyp ERR! node-gyp -v v4.0.0
gyp ERR! not ok

Failed with exit code: 1
    at SafeSubscriber._error (D:\study\RoboTerra\desktop\frontend\electron\node_modules\spawn-rx\lib\src\index.js:267:84)
    at SafeSubscriber.__tryOrUnsub (D:\study\RoboTerra\desktop\frontend\electron\node_modules\rxjs\internal\Subscriber.js:205:16)
    at SafeSubscriber.error (D:\study\RoboTerra\desktop\frontend\electron\node_modules\rxjs\internal\Subscriber.js:156:26)
    at Subscriber._error (D:\study\RoboTerra\desktop\frontend\electron\node_modules\rxjs\internal\Subscriber.js:92:26)
    at Subscriber.error (D:\study\RoboTerra\desktop\frontend\electron\node_modules\rxjs\internal\Subscriber.js:72:18)
    at MapSubscriber.Subscriber._error (D:\study\RoboTerra\desktop\frontend\electron\node_modules\rxjs\internal\Subscriber.js:92:26)
    at MapSubscriber.Subscriber.error (D:\study\RoboTerra\desktop\frontend\electron\node_modules\rxjs\internal\Subscriber.js:72:18)
    at SafeSubscriber._next (D:\study\RoboTerra\desktop\frontend\electron\node_modules\spawn-rx\lib\src\index.js:242:65)
    at SafeSubscriber.__tryOrUnsub (D:\study\RoboTerra\desktop\frontend\electron\node_modules\rxjs\internal\Subscriber.js:205:16)
    at SafeSubscriber.next (D:\study\RoboTerra\desktop\frontend\electron\node_modules\rxjs\internal\Subscriber.js:143:22)
npm ERR! code ELIFECYCLE
npm ERR! errno 4294967295
npm ERR! test@1.0.0 rebuild: `cd ./node_modules/.bin && electron-rebuild --force --module-dir=../../`
npm ERR! Exit status 4294967295
npm ERR!
npm ERR! Failed at the test@1.0.0 rebuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\TinyNight\AppData\Roaming\npm-cache\_logs\2019-07-03T10_13_29_447Z-debug.log

最后一行的日志文件是:

0 info it worked if it ends with ok
1 verbose cli [ 'D:\\ToolsF\\nodeJS\\node.exe',
1 verbose cli   'D:\\ToolsF\\nodeJS\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'rebuild' ]
2 info using npm@5.6.0
3 info using node@v8.10.0
4 verbose run-script [ 'prerebuild', 'rebuild', 'postrebuild' ]
5 info lifecycle test@1.0.0~prerebuild: test@1.0.0
6 info lifecycle test@1.0.0~rebuild: test@1.0.0
7 verbose lifecycle test@1.0.0~rebuild: unsafe-perm in lifecycle true
8 verbose lifecycle test@1.0.0~rebuild: PATH: D:\ToolsF\nodeJS\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\study\RoboTerra\desktop\frontend\electron\node_modules\.bin;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\ia32\compiler;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Haskell\bin;D:\study\Courses\CS 456\Haskell8.2.2\8.2.2\lib\extralibs\bin;D:\study\Courses\CS 456\Haskell8.2.2\8.2.2\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Git\cmd;C:\Program Files (x86)\GtkSharp\2.12\bin;D:\study\Courses\CS 456\Haskell8.2.2\8.2.2\mingw\bin;D:\ToolsF\nodeJS\;C:\Users\TinyNight\.windows-build-tools\python27\;C:\Users\TinyNight\AppData\Roaming\npm\node_modules\cnpm\node_modules\npminstall\node-gyp-bin;C:\Users\TinyNight\AppData\Roaming\npm\node_modules\windows-build-tools\node_modules\.bin;C:\Users\TinyNight\AppData\Roaming\npm\node_modules\windows-build-tools\node_modules\.bin;C:\Users\TinyNight\AppData\Roaming\cabal\bin;D:\study\Courses\CS 456\Haskell8.2.2\stack\bin;C:\Users\TinyNight\AppData\Local\Microsoft\WindowsApps;D:\code\compiler\python3;D:\code\compiler\python2;C:\Users\TinyNight\AppData\Roaming\npm
9 verbose lifecycle test@1.0.0~rebuild: CWD: D:\study\RoboTerra\desktop\frontend\electron
10 silly lifecycle test@1.0.0~rebuild: Args: [ '/d /s /c',
10 silly lifecycle   'cd ./node_modules/.bin && electron-rebuild --force --module-dir=../../' ]
11 silly lifecycle test@1.0.0~rebuild: Returned: code: 4294967295  signal: null
12 info lifecycle test@1.0.0~rebuild: Failed to exec rebuild script
13 verbose stack Error: test@1.0.0 rebuild: `cd ./node_modules/.bin && electron-rebuild --force --module-dir=../../`
13 verbose stack Exit status 4294967295
13 verbose stack     at EventEmitter.<anonymous> (D:\ToolsF\nodeJS\node_modules\npm\node_modules\npm-lifecycle\index.js:285:16)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at EventEmitter.emit (events.js:214:7)
13 verbose stack     at ChildProcess.<anonymous> (D:\ToolsF\nodeJS\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at ChildProcess.emit (events.js:214:7)
13 verbose stack     at maybeClose (internal/child_process.js:925:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid test@1.0.0
15 verbose cwd D:\study\RoboTerra\desktop\frontend\electron
16 verbose Windows_NT 10.0.15063
17 verbose argv "D:\\ToolsF\\nodeJS\\node.exe" "D:\\ToolsF\\nodeJS\\node_modules\\npm\\bin\\npm-cli.js" "run" "rebuild"
18 verbose node v8.10.0
19 verbose npm  v5.6.0
20 error code ELIFECYCLE
21 error errno 4294967295
22 error test@1.0.0 rebuild: `cd ./node_modules/.bin && electron-rebuild --force --module-dir=../../`
22 error Exit status 4294967295
23 error Failed at the test@1.0.0 rebuild script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 4294967295, true ]

我有节点v8.10.0,并且

"dependencies": {
    "electron": "^5.0.6",
    "ffi": "^2.3.0",
    "ref": "^1.3.5",
    "ref-struct": "^1.1.0",
    "windows-build-tools": "^4.0.0"
  },
  "devDependencies": {
    "electron-rebuild": "^1.8.5"
  }

2 个答案:

答案 0 :(得分:1)

这是因为FFI的正式版本不支持电子5。我在Github上询问并得到答复: https://github.com/electron/electron-rebuild/issues/308

我用了旧版的电子,成功了。

答案 1 :(得分:0)

官方ffi不支持Electron 5和Node v10。尝试使用ffi-napi