nwjs / nw-gyp

native addon build tool for node-webkit
MIT License
195 stars 46 forks source link

node-gyp to build addons #64

Closed Kaskarl closed 7 years ago

Kaskarl commented 9 years ago

0、 os : Windows_NT 6.1.7601(win7 64b) vs : 2008 + 2012 python : 2.7.3 node.js : 0.12.0 nw-gyp : 0.12.4 nw : 0.12.0(node-webkit)

1、install nw.js (64b) from https://nodejs.org/download/ 2、npm install -g nw-gyp --msvs_version=2012 --save-dev 3、npm install -g nw --msvs_version=2012 --save-dev

4、nw-gyp configure --target=0.12.0 --msvs_version=2012 then err:

D:\nw.js\nw_native_dll_sample-master\app>nw-gyp configure --target=0.12.0 --msvs-v ersion=2012 gyp info it worked if it ends with ok gyp info using nw-gyp@0.12.4 gyp info using node@0.12.0 | win32 | x64 gyp http GET http://node-webkit.s3.amazonaws.com/v0.12.0/nw-headers-v0.12.0.tar.gz gyp WARN install got an error, rolling back install gyp ERR! configure error gyp ERR! stack Error: read ECONNRESET gyp ERR! stack at exports._errnoException (util.js:746:11) gyp ERR! stack at TCP.onread (net.js:550:26) gyp ERR! System Windows_NT 6.1.7601 gyp ERR! command "node" "C:\Users\admin\AppData\Roaming\npm\node_modules\ nw-gyp\bin\nw-gyp.js" "configure" "target=0.12.0" gyp ERR! cwd D:\nw.js\nw_native_dll_sample-master\app gyp ERR! node -v v0.12.0 gyp ERR! nw-gyp -v v0.12.4 gyp ERR! not ok

??? when I have a VPN to do it again. Success !!!

5、npm install -g ref --msvs_version=2012 --save-dev 6、npm install -g ffi --msvs_version=2012 --save-dev then err:

... ... ... c:\users\admin\appdata\roaming\npm\node_modules\ffi\src\ffi.h(57): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int (..\src\ffi.cc) [C:\Users \admin\AppData\Ro aming\npm\node_modules\ffi\build\ffi_bindings.vcxproj] c:\users\admin\appdata\roaming\npm\node_modules\ffi\src\ffi.h(57): error C2143: 语法错误 : 缺少“,”(在“&”的前面) (..\src\ffi.cc) [C:\Users\admin\AppData\Roa ming\npm\node _modules\ffi\build\ffi_bindings.vcxproj] c:\users\admin\appdata\roaming\npm\node_modules\ffi\src\ffi.h(58): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int (..\src\ffi.cc) [C:\Users \admin\AppData\Ro aming\npm\node_modules\ffi\build\ffi_bindings.vcxproj] c:\users\admin\appdata\roaming\npm\node_modules\ffi\src\ffi.h(58): error C2143: 语法错误 : 缺少“,”(在“&”的前面) (..\src\ffi.cc) [C:\Users\admin\AppData\Roa ming\npm\node _modules\ffi\build\ffi_bindings.vcxproj] c:\users\admin\appdata\roaming\npm\node_modules\ffi\src\ffi.h(59): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int (..\src\ffi.cc) [C:\Users \admin\AppData\Ro aming\npm\node_modules\ffi\build\ffi_bindings.vcxproj] c:\users\admin\appdata\roaming\npm\node_modules\ffi\src\ffi.h(59): error C2143: 语法错误 : 缺少“,”(在“&”的前面) (..\src\ffi.cc) [C:\Users\admin\AppData\Roa ming\npm\node _modules\ffi\build\ffi_bindings.vcxproj] c:\users\admin\appdata\roaming\npm\node_modules\ffi\src\ffi.h(60): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int (..\src\ffi.cc) [C:\Users \admin\AppData\Ro aming\npm\node_modules\ffi\build\ffi_bindings.vcxproj] c:\users\admin\appdata\roaming\npm\node_modules\ffi\src\ffi.h(60): error C2143: 语法错误 : 缺少“,”(在“&”的前面) (..\src\ffi.cc) [C:\Users\admin\AppData\Roa ming\npm\node _modules\ffi\build\ffi_bindings.vcxproj] c:\users\admin\appdata\roaming\npm\node_modules\ffi\src\ffi.h(64): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int (..\src\ffi.cc) [C:\Users \admin\AppData\Ro aming\npm\node_modules\ffi\build\ffi_bindings.vcxproj] c:\users\admin\appdata\roaming\npm\node_modules\ffi\src\ffi.h(64): error C2143: 语法错误 : 缺少“,”(在“&”的前面) (..\src\ffi.cc) [C:\Users\admin\AppData\Roa ming\npm\node _modules\ffi\build\ffi_bindings.vcxproj] c:\users\admin\appdata\roaming\npm\node_modules\ffi\src\ffi.h(94): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int (..\src\ffi.cc) [C:\Users \admin\AppData\Ro aming\npm\node_modules\ffi\build\ffi_bindings.vcxproj] c:\users\admin\appdata\roaming\npm\node_modules\ffi\src\ffi.h(94): error C2143: 语法错误 : 缺少“,”(在“&”的前面) (..\src\ffi.cc) [C:\Users\admin\AppData\Roa ming\npm\node _modules\ffi\build\ffi_bindings.vcxproj] c:\users\admin\appdata\roaming\npm\node_modules\ffi\src\ffi.h(57): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int (..\src\callback_info.cc) [C:\Users\admin\ AppData\Roaming\npm\node_modules\ffi\build\ffi_bindings.vcxproj] c:\users\admin\appdata\roaming\npm\node_modules\ffi\src\ffi.h(57): error C2143: 语法错误 : 缺少“,”(在“&”的前面) (..\src\callback_info.cc) [C:\Users\admin\A ppData\Roamin g\npm\node_modules\ffi\build\ffi_bindings.vcxproj] c:\users\admin\appdata\roaming\npm\node_modules\ffi\src\ffi.h(58): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int (..\src\callback_info.cc) [C:\Users\admin\ AppData\Roaming\npm\node_modules\ffi\build\ffi_bindings.vcxproj] ..\src\ffi.cc(19): error C2248: “v8::HandleScope::HandleScope”: 无法访问 prote cted 成员(在“v8::HandleScope”类中声明) [C:\Users\admin\AppData\Roaming\npm\node_mod ules\ffi \build\ffi_bindings.vcxproj] ... ... ... ..\src\ffi.cc(141): error C3861: “NewSymbol”: 找不到标识符 [C:\Users\admin\App Data\Ro aming\npm\node_modules\ffi\build\ffi_bindings.vcxproj] ..\src\ffi.cc(141): fatal error C1003: 错误计数超过 100;正在停止编译 [C:\Users\ admin\AppDat a\Roaming\npm\node_modules\ffi\build\ffi_bindings.vcxproj] gyp ERR! build error gyp ERR! stack Error: C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe failed with exit code: 1 gyp ERR! stack at ChildProcess.onExit (F:\Program Files\nodejs\node_modules\ npm\node_modules\node-gyp\lib\build.js:267:23) gyp ERR! stack at ChildProcess.emit (events.js:110:17) gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1067 :12) gyp ERR! System Windows_NT 6.1.7601 gyp ERR! command "node" "F:\Program Files\nodejs\node_modules\npm\node_modu les\node-gyp\bin\node-gyp.js" "rebuild" gyp ERR! cwd C:\Users\admin\AppData\Roaming\npm\node_modules\ffi gyp ERR! node -v v0.12.0 gyp ERR! node-gyp -v v1.0.2 gyp ERR! not ok npm ERR! Windows_NT 6.1.7601 npm ERR! argv "F:\Program Files\nodejs\node.exe" "F:\Program Files\nodejs \node_modules\npm\bin\npm-cli.js" "install" "-g" "ffi" "--msvs_version=2012" "--save-dev" npm ERR! node v0.12.0 npm ERR! npm v2.5.1 npm ERR! code ELIFECYCLE

npm ERR! ffi@1.2.7 install: node-gyp rebuild npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the ffi@1.2.7 install script 'node-gyp rebuild'. npm ERR! This is most likely a problem with the ffi package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node-gyp rebuild npm ERR! You can get their info via: npm ERR! npm owner ls ffi npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request: npm ERR! D:\nw.js\nw_native_dll_sample-master\app\npm-debug.log

???

ghostoy commented 9 years ago

The error message shows you are using "--target=0.11.6", instead of "--target=0.12.0". It's incorrect.

And the failure above is caused by not able to download header files. I suggest you test the URL shown above with your browser. If you can't access to that file in your browser, please check your network connection.

Kaskarl commented 9 years ago

@ghostoy I'm sorry, I paste the wrong information that confusion of the two command returns the information. (nw-gyp configure --target=0.12.0 --msvs_version=2012) (nw-gyp configure --target=0.11.6 --msvs_version=2012)

now I update again, As you say I need check my network connection.

I have another question, it is necessary to Get http://node-webkit.s3.amazonaws.com/v0.12.0/nw-headers-v0.12.0.tar.gz

I don't have a VPN, I download it in oher way. How should I handle it.

ghostoy commented 9 years ago

You can setup nw-headers manually, but not recommended. Following steps may help:

  1. Download header files
  2. Download lib files for ia32 and x64
  3. Extract header files to a temp folder and move node/* to /.nw-gyp/0.12.0/
  4. Copy lib files to /.nw-gyp/0.12.0/ia32 and /.nw-gyp/0.12.0/x64 separately

Then nw-gyp should be working.

Kaskarl commented 9 years ago

@ghostoy when I have a VPN to do it again. Success !!! thank you very much. But I met othre trouble

npm install -g ffi --msvs_version=2012 --save-dev

gyp ERR! build error gyp ERR! stack Error: C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe failed with exit code: 1 gyp ERR! stack at ChildProcess.onExit (F:\Program Files\nodejs\node_modules\ npm\node_modules\node-gyp\lib\build.js:267:23) gyp ERR! stack at ChildProcess.emit (events.js:110:17) gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1067 :12) gyp ERR! System Windows_NT 6.1.7601 gyp ERR! command "node" "F:\Program Files\nodejs\node_modules\npm\node_modu les\node-gyp\bin\node-gyp.js" "rebuild" gyp ERR! cwd C:\Users\admin\AppData\Roaming\npm\node_modules\ffi gyp ERR! node -v v0.12.0 gyp ERR! node-gyp -v v1.0.2 gyp ERR! not ok npm ERR! Windows_NT 6.1.7601 npm ERR! argv "F:\Program Files\nodejs\node.exe" "F:\Program Files\nodejs \node_modules\npm\bin\npm-cli.js" "install" "-g" "ffi" "--msvs_version=2012" "--save-dev" npm ERR! node v0.12.0 npm ERR! npm v2.5.1 npm ERR! code ELIFECYCLE

npm ERR! ffi@1.2.7 install: node-gyp rebuild npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the ffi@1.2.7 install script 'node-gyp rebuild'. npm ERR! This is most likely a problem with the ffi package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node-gyp rebuild npm ERR! You can get their info via: npm ERR! npm owner ls ffi npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request: npm ERR! D:\nw.js\nw_native_dll_sample-master\app\npm-debug.log

ghostoy commented 9 years ago

For nw11 or later, you should use msvs 2013. And node-ffi doesn't work with node.js 0.12.0 yet. See node-ffi/node-ffi#187

Kaskarl commented 9 years ago

hi, I had a simple example like that:(example) package.json index.html test.js binding.gyp binding.cpp

then: nw-gyp configure --msvs_version=2012 nw-gyp build --msvs_version=2012

result: build/release/binding.node

then: nw example

success

1、but, then i copy all of files(package.json, index.html, test.js, binding.node) make a zip 2、rename the file extension from .zip to .nw 3、nw.exe example.nw (success !!!) 4、ps:(dl.nwjs.io/v0.12.0) nwjs-v0.12.0-win-x64.zip 5、copy /b nw.exe+example.nw example.exe 6、start example.exe uncaught error: the specified module could not be found. module.js:346 c:\users\admin\appdata\local\temp\nw8392_7885\binding.node

???

justinmchase commented 9 years ago

This is happening to me also. The error seems to be because you've renamed the executable from nw.exe to example.exe and your native module has a dynamic link on nw.exe specifically:

nw dep

ghostoy commented 7 years ago

This issue should be fixed with latest NW.js and nw-gyp. So close it.