justinlatimer / node-midi

A node.js wrapper for RtMidi providing MIDI I/O
MIT License
741 stars 118 forks source link

'Error: %1 is not a valid Win32 application' under Node-Webkit/Windows 7 #53

Closed ttaluy closed 9 years ago

ttaluy commented 10 years ago

Dear all,

I have tried to use node-midi under node-webkit, but when I try to execute this simple script:

var midi = require('midi');
var input = new midi.input();

window.onload = function() {
    console.log(input.getPortCount());
}

I get the following error:

Error: %1 is not a valid Win32 application. 
c:\Users\ttaluy\AppData\Local\Temp\nw2524_20403\node_modules\midi\build\Release\midi.node
    at Module.load (module.js:352:32)
    at Function.Module._load (module.js:308:12)
    at Module.require (module.js:360:17)
    at require (module.js:376:17)
    at bindings (C:\Users\ttaluy\AppData\Local\Temp\nw2524_20403\node_modules\midi\node_modules\bindings\bindings.js:76:44)
    at Object.eval (C:\Users\ttaluy\AppData\Local\Temp\nw2524_20403\node_modules\midi\midi.js:1:93)
    at Module._compile (module.js:452:26)
    at Object.Module._extensions..js (module.js:470:10)
    at Module.load (module.js:352:32)
    at Function.Module._load (module.js:308:12)

It looks like this is a path-related issue, maybe a path having empty spaces or something not being interpreted correctly under Microsoft Windows? I am using Windows 7 Ultimate SP1 64-bit with node-webkit-v0.9.2, Python 2.7.7 and Visual C++. I had a couple of warnings during the installation through npm, I did not note these down, but they can be easily reproduced in case you need them.

Thank you!

drewish commented 10 years ago

Please include any warnings encountered during installation. Also I'd suggest reviewing the instructions on https://github.com/rogerwang/node-webkit/wiki/Using-Node-modules#3rd-party-modules-with-cc-addons and including the commands you used to installed the module.

ttaluy commented 10 years ago

Hello drewish,

I was away from keyboard for the weekend, here is the cmd dump of npm install midi.

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\node-webkit-lab\midi-test>npm install midi
|

> midi@0.9.0 install C:\node-webkit-lab\midi-test\node_modules\midi
> node-gyp rebuild

C:\node-webkit-lab\midi-test\node_modules\midi>node "C:\Program Files\nodejs\nod
e_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" reb
uild
Building the projects in this solution one at a time. To enable parallel build,
please add the "/m" switch.
  node-midi.cpp
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\vector(318): war
ning C4506: no definition for inline function 'v8::Persistent<v8::Object> v8::P
ersistent<v8::Object>::New(v8::Handle<v8::Object>)' [C:\node-webkit-lab\midi-te
st\node_modules\midi\build\midi.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\vector(318): war
ning C4506: no definition for inline function 'v8::Persistent<v8::FunctionTempl
ate> v8::Persistent<v8::FunctionTemplate>::New(v8::Handle<v8::FunctionTemplate>
)' [C:\node-webkit-lab\midi-test\node_modules\midi\build\midi.vcxproj]
     Creating library C:\node-webkit-lab\midi-test\node_modules\midi\build\Rele
  ase\midi.lib and object C:\node-webkit-lab\midi-test\node_modules\midi\build\
  Release\midi.exp
  Generating code
  Finished generating code
  midi.vcxproj -> C:\node-webkit-lab\midi-test\node_modules\midi\build\Release\
  \midi.node
midi@0.9.0 node_modules\midi
└── bindings@1.2.1

C:\node-webkit-lab\midi-test>

I am going to have a look at the link you provided, I tried to install this module as if the whole thing was a regular Node.js project, there might be additional instructions indeed.

Thanks once again!

ttaluy commented 10 years ago

OK - it seems like I have to rebuild the module with nw-gyp instead of node-gyp and these are the errors I get when I do this:

C:\node-webkit-lab\webaudio-midi-synth\node_modules\midi>nw-gyp rebuild --target
=0.9.2

gyp info it worked if it ends with ok
gyp info using nw-gyp@0.12.2
gyp info using node@0.10.29 | win32 | x64
gyp http GET http://node-webkit.s3.amazonaws.com/v0.9.2/nw-headers-v0.9.2.tar.gz

gyp http 200 http://node-webkit.s3.amazonaws.com/v0.9.2/nw-headers-v0.9.2.tar.gz

gyp http GET http://node-webkit.s3.amazonaws.com/v0.9.2/nw.lib
gyp http 200 http://node-webkit.s3.amazonaws.com/v0.9.2/nw.lib
gyp info spawn python
gyp info spawn args [ 'C:\\Users\\ttaluy\\AppData\\Roaming\\npm\\node_modules\\n
w-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   '-G',
gyp info spawn args   'msvs_version=auto',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\node-webkit-lab\\webaudio-midi-synth\\node_modules\\m
idi\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\ttaluy\\AppData\\Roaming\\npm\\node_modules\\n
w-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\ttaluy\\.nw-gyp\\0.9.2\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=C:\\Users\\ttaluy\\.nw-gyp\\0.9.2',
gyp info spawn args   '-Dmodule_root_dir=C:\\node-webkit-lab\\webaudio-midi-synt
h\\node_modules\\midi',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--generator-output',
gyp info spawn args   'C:\\node-webkit-lab\\webaudio-midi-synth\\node_modules\\m
idi\\build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp info spawn C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe
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=Win32' ]
Building the projects in this solution one at a time. To enable parallel build,
please add the "/m" switch.
  node-midi.cpp
..\src\node-midi.cpp(22): error C2664: 'v8::Local<v8::FunctionTemplate> v8::Fun
ctionTemplate::New(v8::FunctionCallback,v8::Handle<v8::Value>,v8::Handle<v8::Si
gnature>,int)' : cannot convert argument 1 from 'v8::Handle<v8::Value> (__cdecl
 *)(const v8::Arguments &)' to 'v8::FunctionCallback' [C:\node-webkit-lab\webau
dio-midi-synth\node_modules\midi\build\midi.vcxproj]
          Incompatible calling conventions for UDT return value
..\src\node-midi.cpp(28): error C2664: 'void node::NODE_SET_PROTOTYPE_METHOD(v8
::Handle<v8::FunctionTemplate>,const char *,v8::FunctionCallback)' : cannot con
vert argument 1 from 'v8::Persistent<T,v8::NonCopyablePersistentTraits<T>>' to
'v8::Handle<v8::FunctionTemplate>' [C:\node-webkit-lab\webaudio-midi-synth\node
_modules\midi\build\midi.vcxproj]
          with
          [
              T=v8::FunctionTemplate
          ]
          No user-defined-conversion operator available that can perform this c
  onversion, or the operator cannot be called
..\src\node-midi.cpp(29): error C2664: 'void node::NODE_SET_PROTOTYPE_METHOD(v8
::Handle<v8::FunctionTemplate>,const char *,v8::FunctionCallback)' : cannot con
vert argument 1 from 'v8::Persistent<T,v8::NonCopyablePersistentTraits<T>>' to
'v8::Handle<v8::FunctionTemplate>' [C:\node-webkit-lab\webaudio-midi-synth\node
_modules\midi\build\midi.vcxproj]
          with
          [
              T=v8::FunctionTemplate
          ]
          No user-defined-conversion operator available that can perform this c
  onversion, or the operator cannot be called
..\src\node-midi.cpp(31): error C2664: 'void node::NODE_SET_PROTOTYPE_METHOD(v8
::Handle<v8::FunctionTemplate>,const char *,v8::FunctionCallback)' : cannot con
vert argument 1 from 'v8::Persistent<T,v8::NonCopyablePersistentTraits<T>>' to
'v8::Handle<v8::FunctionTemplate>' [C:\node-webkit-lab\webaudio-midi-synth\node
_modules\midi\build\midi.vcxproj]
          with
          [
              T=v8::FunctionTemplate
          ]
          No user-defined-conversion operator available that can perform this c
  onversion, or the operator cannot be called
..\src\node-midi.cpp(32): error C2664: 'void node::NODE_SET_PROTOTYPE_METHOD(v8
::Handle<v8::FunctionTemplate>,const char *,v8::FunctionCallback)' : cannot con
vert argument 1 from 'v8::Persistent<T,v8::NonCopyablePersistentTraits<T>>' to
'v8::Handle<v8::FunctionTemplate>' [C:\node-webkit-lab\webaudio-midi-synth\node
_modules\midi\build\midi.vcxproj]
          with
          [
              T=v8::FunctionTemplate
          ]
          No user-defined-conversion operator available that can perform this c
  onversion, or the operator cannot be called
..\src\node-midi.cpp(33): error C2664: 'void node::NODE_SET_PROTOTYPE_METHOD(v8
::Handle<v8::FunctionTemplate>,const char *,v8::FunctionCallback)' : cannot con
vert argument 1 from 'v8::Persistent<T,v8::NonCopyablePersistentTraits<T>>' to
'v8::Handle<v8::FunctionTemplate>' [C:\node-webkit-lab\webaudio-midi-synth\node
_modules\midi\build\midi.vcxproj]
          with
          [
              T=v8::FunctionTemplate
          ]
          No user-defined-conversion operator available that can perform this c
  onversion, or the operator cannot be called
..\src\node-midi.cpp(35): error C2664: 'void node::NODE_SET_PROTOTYPE_METHOD(v8
::Handle<v8::FunctionTemplate>,const char *,v8::FunctionCallback)' : cannot con
vert argument 1 from 'v8::Persistent<T,v8::NonCopyablePersistentTraits<T>>' to
'v8::Handle<v8::FunctionTemplate>' [C:\node-webkit-lab\webaudio-midi-synth\node
_modules\midi\build\midi.vcxproj]
          with
          [
              T=v8::FunctionTemplate
          ]
          No user-defined-conversion operator available that can perform this c
  onversion, or the operator cannot be called
..\src\node-midi.cpp(167): error C2664: 'v8::Local<v8::FunctionTemplate> v8::Fu
nctionTemplate::New(v8::FunctionCallback,v8::Handle<v8::Value>,v8::Handle<v8::S
ignature>,int)' : cannot convert argument 1 from 'v8::Handle<v8::Value> (__cdec
l *)(const v8::Arguments &)' to 'v8::FunctionCallback' [C:\node-webkit-lab\weba
udio-midi-synth\node_modules\midi\build\midi.vcxproj]
          Incompatible calling conventions for UDT return value
..\src\node-midi.cpp(174): error C2664: 'void node::NODE_SET_PROTOTYPE_METHOD(v
8::Handle<v8::FunctionTemplate>,const char *,v8::FunctionCallback)' : cannot co
nvert argument 1 from 'v8::Persistent<T,v8::NonCopyablePersistentTraits<T>>' to
 'v8::Handle<v8::FunctionTemplate>' [C:\node-webkit-lab\webaudio-midi-synth\nod
e_modules\midi\build\midi.vcxproj]
          with
          [
              T=v8::FunctionTemplate
          ]
          No user-defined-conversion operator available that can perform this c
  onversion, or the operator cannot be called
..\src\node-midi.cpp(175): error C2664: 'void node::NODE_SET_PROTOTYPE_METHOD(v
8::Handle<v8::FunctionTemplate>,const char *,v8::FunctionCallback)' : cannot co
nvert argument 1 from 'v8::Persistent<T,v8::NonCopyablePersistentTraits<T>>' to
 'v8::Handle<v8::FunctionTemplate>' [C:\node-webkit-lab\webaudio-midi-synth\nod
e_modules\midi\build\midi.vcxproj]
          with
          [
              T=v8::FunctionTemplate
          ]
          No user-defined-conversion operator available that can perform this c
  onversion, or the operator cannot be called
..\src\node-midi.cpp(177): error C2664: 'void node::NODE_SET_PROTOTYPE_METHOD(v
8::Handle<v8::FunctionTemplate>,const char *,v8::FunctionCallback)' : cannot co
nvert argument 1 from 'v8::Persistent<T,v8::NonCopyablePersistentTraits<T>>' to
 'v8::Handle<v8::FunctionTemplate>' [C:\node-webkit-lab\webaudio-midi-synth\nod
e_modules\midi\build\midi.vcxproj]
          with
          [
              T=v8::FunctionTemplate
          ]
          No user-defined-conversion operator available that can perform this c
  onversion, or the operator cannot be called
..\src\node-midi.cpp(178): error C2664: 'void node::NODE_SET_PROTOTYPE_METHOD(v
8::Handle<v8::FunctionTemplate>,const char *,v8::FunctionCallback)' : cannot co
nvert argument 1 from 'v8::Persistent<T,v8::NonCopyablePersistentTraits<T>>' to
 'v8::Handle<v8::FunctionTemplate>' [C:\node-webkit-lab\webaudio-midi-synth\nod
e_modules\midi\build\midi.vcxproj]
          with
          [
              T=v8::FunctionTemplate
          ]
          No user-defined-conversion operator available that can perform this c
  onversion, or the operator cannot be called
..\src\node-midi.cpp(179): error C2664: 'void node::NODE_SET_PROTOTYPE_METHOD(v
8::Handle<v8::FunctionTemplate>,const char *,v8::FunctionCallback)' : cannot co
nvert argument 1 from 'v8::Persistent<T,v8::NonCopyablePersistentTraits<T>>' to
 'v8::Handle<v8::FunctionTemplate>' [C:\node-webkit-lab\webaudio-midi-synth\nod
e_modules\midi\build\midi.vcxproj]
          with
          [
              T=v8::FunctionTemplate
          ]
          No user-defined-conversion operator available that can perform this c
  onversion, or the operator cannot be called
..\src\node-midi.cpp(181): error C2664: 'void node::NODE_SET_PROTOTYPE_METHOD(v
8::Handle<v8::FunctionTemplate>,const char *,v8::FunctionCallback)' : cannot co
nvert argument 1 from 'v8::Persistent<T,v8::NonCopyablePersistentTraits<T>>' to
 'v8::Handle<v8::FunctionTemplate>' [C:\node-webkit-lab\webaudio-midi-synth\nod
e_modules\midi\build\midi.vcxproj]
          with
          [
              T=v8::FunctionTemplate
          ]
          No user-defined-conversion operator available that can perform this c
  onversion, or the operator cannot be called
..\src\node-midi.cpp(211): error C2661: 'v8::Local<v8::Value>::New' : no overlo
aded function takes 1 arguments [C:\node-webkit-lab\webaudio-midi-synth\node_mo
dules\midi\build\midi.vcxproj]
..\src\node-midi.cpp(217): error C2661: 'v8::Local<v8::Value>::New' : no overlo
aded function takes 1 arguments [C:\node-webkit-lab\webaudio-midi-synth\node_mo
dules\midi\build\midi.vcxproj]
..\src\node-midi.cpp(218): error C2248: 'node::ObjectWrap::handle_' : cannot ac
cess private member declared in class 'node::ObjectWrap' [C:\node-webkit-lab\we
baudio-midi-synth\node_modules\midi\build\midi.vcxproj]
          C:\Users\ttaluy\.nw-gyp\0.9.2\src\node_object_wrap.h(129) : see decla
  ration of 'node::ObjectWrap::handle_'
          C:\Users\ttaluy\.nw-gyp\0.9.2\src\node_object_wrap.h(31) : see declar
  ation of 'node::ObjectWrap'
..\src\node-midi.cpp(218): error C2665: 'node::MakeCallback' : none of the 3 ov
erloads could convert all the argument types [C:\node-webkit-lab\webaudio-midi-
synth\node_modules\midi\build\midi.vcxproj]
          C:\Users\ttaluy\.nw-gyp\0.9.2\src\node.h(113): could be 'v8::Handle<v
  8::Value> node::MakeCallback(const v8::Handle<v8::Object>,const v8::Handle<v8
  ::Function>,int,v8::Handle<v8::Value> *)'
          C:\Users\ttaluy\.nw-gyp\0.9.2\src\node.h(108): or       'v8::Handle<v
  8::Value> node::MakeCallback(const v8::Handle<v8::Object>,const v8::Handle<v8
  ::String>,int,v8::Handle<v8::Value> *)'
          C:\Users\ttaluy\.nw-gyp\0.9.2\src\node.h(103): or       'v8::Handle<v
  8::Value> node::MakeCallback(const v8::Handle<v8::Object>,const char *,int,v8
  ::Handle<v8::Value> *)'
          while trying to match the argument list '(v8::Persistent<v8::Object,v
  8::NonCopyablePersistentTraits<T>>, const char *, int, v8::Local<v8::Value> [
  3])'
          with
          [
              T=v8::Object
          ]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe` fail
ed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\ttaluy\AppData\Roaming\npm\n
ode_modules\nw-gyp\lib\build.js:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:809:
12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\\Users\\ttaluy\\AppData\\Roaming\\npm\\node_modules\
\nw-gyp\\bin\\nw-gyp.js" "rebuild" "--target=0.9.2"
gyp ERR! cwd C:\node-webkit-lab\webaudio-midi-synth\node_modules\midi
gyp ERR! node -v v0.10.29
gyp ERR! nw-gyp -v v0.12.2
gyp ERR! not ok

C:\node-webkit-lab\webaudio-midi-synth\node_modules\midi>
ttaluy commented 10 years ago

Hello drewish,

Any news or recommendations on this?

Thanks!

drewish commented 10 years ago

What version of node is it trying to compile against? 0.11.x? You might try this branch: https://github.com/justinlatimer/node-midi/pull/52

ttaluy commented 10 years ago

Node.js in Node-WebKit is 0.11.9, I will try the branch you mention and let you know if it works better.

drewish commented 10 years ago

Ah yeah then leave a comment on that PR too if the 0.11.x part looks good.

ttaluy commented 10 years ago

I still get some errors:

C:\node-webkit-lab\midi-synth>cd node-midi

C:\node-webkit-lab\midi-synth\node-midi>nw-gyp rebuild --target
gyp info it worked if it ends with ok
gyp info using nw-gyp@0.12.2
gyp info using node@0.10.29 | win32 | x64
gyp ERR! configure error
gyp ERR! stack Error: Invalid version number: true
gyp ERR! stack     at getNodeDir (C:\Users\ttaluy\AppData\Roaming\npm\node_modules\nw-gyp\lib\configure.js:145:25)
gyp ERR! stack     at C:\Users\ttaluy\AppData\Roaming\npm\node_modules\nw-gyp\lib\configure.js:93:9
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:645:7)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at maybeClose (child_process.js:755:16)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:822:5)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\\Users\\ttaluy\\AppData\\Roaming\\npm\\node_modules\\nw-gyp\\bin\\nw-gyp.js" "rebuild" "--target"
gyp ERR! cwd C:\node-webkit-lab\midi-synth\node-midi
gyp ERR! node -v v0.10.29
gyp ERR! nw-gyp -v v0.12.2
gyp ERR! not ok

I don't get it, do you think is happening because the two versions of Node.js (local and Node-WebKit) don't match?

drewish commented 10 years ago

Oh yeah I'd try to get those matching or figure out why the different versions are coming into play.

atommarvel commented 9 years ago

@ttaluy did you get to a solution for this? I was about to try this out when I saw this issue.

ttaluy commented 9 years ago

Hey @atommarvel, as I was busy doing other stuff I put these experiments on hold for for the moment. If you plan to use this in a Node-WebKit environment, try to match the different Node.js & gyp versions and let us know if that works! ;)

drewish commented 9 years ago

I think the switch to using NAN and the fix for https://github.com/justinlatimer/node-midi/pull/63 should have solved this. I'm going to close this. If there are still problems post a comment and I'll reopen it.