santigimeno/node-pcsclite

Windows node-webkit support

Closed this issue · 32 comments

Does this work on windows?

@mn1aC Hi! Sorry for the delay. I somehow missed the notification.
I've this PR: #24 that should allow to use this module in windows. See: #17. Still I haven't been able to test it thoroughly. If you could test it if works for you it'd be great!

mn1aC commented

What with mac?

apt-get install libpcsclite1 libpcsclite-dev

will not work on mac...

node-pcsclite should work on Mac OS X. But the installation procedure is different.

See http://ludovicrousseau.blogspot.fr/2014/09/pcsc-sample-in-javascript-nodejs.html

mn1aC commented

So from what i'm reading the current version should work on Win and Mac OS X?

mn1aC commented

I don's see any installation procedure for Mac OS X at http://ludovicrousseau.blogspot.fr/2014/09/pcsc-sample-in-javascript-nodejs.html

mn1aC commented

I'm using node-webkit (nwjs.io)..

@mn1aC The current status of the module is:

  • Linux: I have a couple of applications in production and have been working correctly for more than a year.
  • Mac OS X: thanks to the help of @LudovicRousseau and others, I know it works. I don't know how stable it is as I don't work in that platform. To make it work in Max OS X I think you have to activate the pcscd service, I think there was a blogpost from @LudovicRousseau explaining how to do that but I can't find the link now.
  • Windows: no support in the last published version (0.3.6). Implemented in the attached_threads branch. See: #24. I'll try to merge it as soon as I can test it properly. Some help would be appreciated
mn1aC commented

Ok @santigimeno I'm going to start looking into windows and after that try it on Mac.
I'll post my findings here...

mn1aC commented

npm install pcsclite (failed)...

I downloaded the folder from git and extracted it in node_modules/pcsclite

nw-gyp rebuild --msvs_version=2013
failed, because 'nan' was not found.
So I did: npm install nan (in the node_modules/pcsclite folder)
Retry: nw-gyp rebuild --msvs_version=2013
But still cannot compile for node-webkit on windows..
Error:

..\src\pcsclite.cpp(1): fatal error C1083: Cannot open include file: 'unistd.h' : No such file or directory [C:\Users\User\Desktop\nw\nw\nw\node_mo dules\pcsclite\build\pcsclite.vcxproj] c:\users\User\desktop\nw\nw\nw\node_modules\pcsclite\src\cardreader .h(7): fatal error C1083: Cannot open include file: 'pthread.h': No such file o r directory (..\src\cardreader.cpp) [C:\Users\User\Desktop\nw\nw\nw \node_modules\pcsclite\build\pcsclite.vcxproj] c:\users\User\desktop\nw\nw\nw\node_modules\pcsclite\src\pcsclite.h (53): error C2146: syntax error : missing ';' before identifier 'm_status_threa d' (..\src\addon.cpp) [C:\Users\User\Desktop\nw\nw\nw\node_modules\ pcsclite\build\pcsclite.vcxproj] c:\users\User\desktop\nw\nw\nw\node_modules\pcsclite\src\pcsclite.h (53): error C4430: missing type specifier - int assumed. Note: C++ does not sup port default-int (..\src\addon.cpp) [C:\Users\User\Desktop\nw\nw\nw \node_modules\pcsclite\build\pcsclite.vcxproj] c:\users\User\desktop\nw\nw\nw\node_modules\pcsclite\src\pcsclite.h (54): error C2146: syntax error : missing ';' before identifier 'm_mutex' (..\s rc\addon.cpp) [C:\Users\User\Desktop\nw\nw\nw\node_modules\pcsclite \build\pcsclite.vcxproj] c:\users\User\desktop\nw\nw\nw\node_modules\pcsclite\src\pcsclite.h (54): error C4430: missing type specifier - int assumed. Note: C++ does not sup port default-int (..\src\addon.cpp) [C:\Users\User\Desktop\nw\nw\nw \node_modules\pcsclite\build\pcsclite.vcxproj] c:\users\User\desktop\nw\nw\nw\node_modules\pcsclite\src\cardreader .h(7): fatal error C1083: Cannot open include file: 'pthread.h': No such file o r directory (..\src\addon.cpp) [C:\Users\User\Desktop\nw\nw\nw\node _modules\pcsclite\build\pcsclite.vcxproj]

mn1aC commented

With node-gyp instead of nw-gyp it's the same error I'm getting

Any idea's how to move forward?

@mn1aC It looks to me you're using the code from master and not from the attached_threads branch as explained in #30 (comment)

mn1aC commented

Downloaded https://github.com/santigimeno/node-pcsclite/tree/attached_threads

nw-gyp rebuild --msvs_version=2013
failed, because 'nan' was not found.
So I did: npm install nan (in the node_modules/pcsclite folder)
Retry: nw-gyp rebuild --msvs_version=2013
But still cannot compile for node-webkit on windows..

..\src\pcsclite.cpp(1): fatal error C1083: Cannot open include file: 'unistd.h' : No such file or directory [C:\Users\Electro Cornelis\Desktop\nw\nw\nw\node_mo dules\pcsclite\build\pcsclite.vcxproj] gyp ERR! build error gyp ERR! stack Error:C:\Program Files\MSBuild\12.0\bin\msbuild.exefailed wit h exit code: 1 gyp ERR! stack at ChildProcess.onExit (C:\Users\Electro Cornelis\AppData\Roa ming\npm\node_modules\nw-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" "C:\\Users\\Electro Cornelis\\AppData\\Roaming\\npm\\nod e_modules\\nw-gyp\\bin\\nw-gyp.js" "rebuild" "--msvs_version=2013" gyp ERR! cwd C:\Users\Electro Cornelis\Desktop\nw\nw\nw\node_modules\pcsclite gyp ERR! node -v v0.12.0 gyp ERR! nw-gyp -v v0.12.4 gyp ERR! not ok

Yeah, that error makes more sense. I have updated the attached_threads branch. Can you try again? Thanks!

mn1aC commented

@santigimeno with the adjusted branch attached_threads I get the following...

nw-gyp rebuild -msvs_version=2013
`* CIL library ( CIL module *) : error LNK2005: "public: __thiscall v8::Escapa
bleHandleScope::~EscapableHandleScope(void)" (??1EscapableHandleScope@v8@@QAE@X
Z) already defined in nw.lib(nw.exe) [C:\Users\Electro Cornelis\Desktop\nw\nw\n
w\node_modules\pcsclite\build\pcsclite.vcxproj]

  • CIL library ( CIL module *) : error LNK2005: "public: static class v8::Func
    tion * __cdecl v8::Function::Cast(class v8::Value *)" (?Cast@Function@v8@@Sapav
    12@PAVValue@2@@z) already defined in nw.lib(nw.exe) [C:\Users\Electro Cornelis
    Desktop\nw\nw\nw\node_modules\pcsclite\build\pcsclite.vcxproj]
  • CIL library ( CIL module *) : error LNK2005: "public: void * __thiscall v8:
    :Object::GetAlignedPointerFromInternalField(int)" (?GetAlignedPointerFromIntern
    alField@Object@v8@@QAEPAXH@Z) already defined in nw.lib(nw.exe) [C:\Users\Elect
    ro Cornelis\Desktop\nw\nw\nw\node_modules\pcsclite\build\pcsclite.vcxproj]
  • CIL library ( CIL module *) : error LNK2005: "public: void __thiscall v8::T
    emplate::Set(class v8::Isolate *,char const *,class v8::Handle)
    " (?Set@Template@v8@@QAEXPAVIsolate@2@PBDV?$Handle@VData@v8@@@2@@z) already def
    ined in nw.lib(nw.exe) [C:\Users\Electro Cornelis\Desktop\nw\nw\nw\node_modules
    \pcsclite\build\pcsclite.vcxproj]
    C:\Users\Electro Cornelis\Desktop\nw\nw\nw\node_modules\pcsclite\build\Release
    pcsclite.node : fatal error LNK1169: one or more multiply defined symbols found
    [C:\Users\Electro Cornelis\Desktop\nw\nw\nw\node_modules\pcsclite\build\pcscli
    te.vcxproj]
    gyp ERR! build error
    gyp ERR! stack Error: C:\Program Files\MSBuild\12.0\bin\msbuild.exe failed wit
    h exit code: 1
    gyp ERR! stack at ChildProcess.onExit (C:\Users\Electro Cornelis\AppData\Roa
    ming\npm\node_modules\nw-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" "C:\Users\Electro Cornelis\AppData\Roaming\npm\nod
    e_modules\nw-gyp\bin\nw-gyp.js" "rebuild" "--msvs_version=2013"
    gyp ERR! cwd C:\Users\Electro Cornelis\Desktop\nw\nw\nw\node_modules\pcsclite
    gyp ERR! node -v v0.12.0
    gyp ERR! nw-gyp -v v0.12.4
    gyp ERR! not ok`

@mn1aC Thanks for the info. A couple of things:

  • Can I see the output of npm ls inside the pcsclite module?
  • Can you simply try to build the pcsclite outside the nw environment? (just using npm ,node-gyp)
mn1aC commented

`pcsclite@0.3.6 C:\Users\Electro Cornelis\Desktop\nw\nw\nw\node_modules\pcsclite
├── UNMET DEPENDENCY bindings@^1.1.0
├── UNMET DEPENDENCY buffertools@^2.1.2
└── nan@1.7.0

npm ERR! missing: buffertools@^2.1.2, required by pcsclite@0.3.6
npm ERR! missing: bindings@^1.1.0, required by pcsclite@0.3.6`

mn1aC commented

Now I did

npm install buffertools
npm install bindings

npm ls gives

pcsclite@0.3.6 C:\Users\Electro Cornelis\Desktop\nw\nw\nw\node_modules\pcsclite ├── bindings@1.2.1 ├── buffertools@2.1.2 └── nan@1.7.0

mn1aC commented

Went into node_modules/pcsclite/node_modules/bindings and did nw-gyp rebuild -msvs_version=2013 (failed)
Went into node_modules/pcsclite/node_modules/buffertools and did nw-gyp rebuild -msvs_version=2013 (worked)

in the node_modules/pcsclite folder nw-gyp rebuild -msvs_version=2013

Error
`* CIL library ( CIL module *) : error LNK2005: "public: __thiscall v8::Escapa
bleHandleScope::~EscapableHandleScope(void)" (??1EscapableHandleScope@v8@@QAE@X
Z) already defined in nw.lib(nw.exe) [C:\Users\Electro Cornelis\Desktop\nw\nw\n
w\node_modules\pcsclite\build\pcsclite.vcxproj]

  • CIL library ( CIL module *) : error LNK2005: "public: static class v8::Func
    tion * __cdecl v8::Function::Cast(class v8::Value *)" (?Cast@Function@v8@@Sapav
    12@PAVValue@2@@z) already defined in nw.lib(nw.exe) [C:\Users\Electro Cornelis
    Desktop\nw\nw\nw\node_modules\pcsclite\build\pcsclite.vcxproj]
  • CIL library ( CIL module *) : error LNK2005: "public: void * __thiscall v8:
    :Object::GetAlignedPointerFromInternalField(int)" (?GetAlignedPointerFromIntern
    alField@Object@v8@@QAEPAXH@Z) already defined in nw.lib(nw.exe) [C:\Users\Elect
    ro Cornelis\Desktop\nw\nw\nw\node_modules\pcsclite\build\pcsclite.vcxproj]
  • CIL library ( CIL module *) : error LNK2005: "public: void __thiscall v8::T
    emplate::Set(class v8::Isolate *,char const *,class v8::Handle)
    " (?Set@Template@v8@@QAEXPAVIsolate@2@PBDV?$Handle@VData@v8@@@2@@z) already def
    ined in nw.lib(nw.exe) [C:\Users\Electro Cornelis\Desktop\nw\nw\nw\node_modules
    \pcsclite\build\pcsclite.vcxproj]
    C:\Users\Electro Cornelis\Desktop\nw\nw\nw\node_modules\pcsclite\build\Release
    pcsclite.node : fatal error LNK1169: one or more multiply defined symbols found
    [C:\Users\Electro Cornelis\Desktop\nw\nw\nw\node_modules\pcsclite\build\pcscli
    te.vcxproj]
    gyp ERR! build error
    gyp ERR! stack Error: C:\Program Files\MSBuild\12.0\bin\msbuild.exe failed wit
    h exit code: 1
    gyp ERR! stack at ChildProcess.onExit (C:\Users\Electro Cornelis\AppData\Roa
    ming\npm\node_modules\nw-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" "C:\Users\Electro Cornelis\AppData\Roaming\npm\nod
    e_modules\nw-gyp\bin\nw-gyp.js" "rebuild" "-msvs_version=2013"
    gyp ERR! cwd C:\Users\Electro Cornelis\Desktop\nw\nw\nw\node_modules\pcsclite
    gyp ERR! node -v v0.12.0
    gyp ERR! nw-gyp -v v0.12.4
    gyp ERR! not ok`
mn1aC commented

in pcsclite folder:
node-gyp configure (OK)
node-gyp build (OK)

so it seems node-webkit needs something different?

@mn1aC I have made a small modification in the attached_threads branch. Can you try again?

mn1aC commented

@santigimeno build worked now. 👍
I'm going to test if the cardreader works now ..

(downloaded attached_threads in folder node_modules/pcsclite)
(went into the folder pcsclite: npm install nan, npm install buffertools, npm install bindings)
(nw-gyp rebuild -msvs_version=2013)

mn1aC commented

@santigimeno in de nwjs code I added:
var pcsc = require('pcsclite'); alert("ok");
but I get the following error in console:
Uncaught Error: Cannot find module './build/Debug/buffertools.node' module.js:329

Any idea's?

npm rebuild?

mn1aC commented

Same problem (I did the npm rebuild in the main folder)

Seems odd to me. Can you try to find a buffertools.node file in the node_modules source tree?

mn1aC commented

I found the buffertools.node file in node_modules/pcsclite/node_modules/buffertools/build/Release folder. Changed the name from Release to Debug and tried again...

Uncaught Error: Invalid access to memorylocation
C:\Users\User\Desktop\nw\nw\nw\node_modules\pcsclite\node_modules\buffertools\build\Debug\buffertools.node (module.js:346)

This is weird, looking at the buffertools code, first it should try to look into the Release folder, then into the Debug folder:

try {
    var buffertools = require('./build/Release/buffertools.node');
} catch (e) {
    var buffertools = require('./build/Debug/buffertools.node');
}

I don't know what's going on. You could try to narrow down the error:

  • Try pcsclite outside nw and see if it works.
  • Try buffertools only in nw and see if it works.
  • etc.
mn1aC commented

Ok I'll keep looking and post my findings here.

@mn1aC Just to be sure:

  • Download the attached_threads branch somewhere.
  • Go to you application root folder and run npm install path-to-pcsclite-module. This command should install and build the module.
  • Run your app
mn1aC commented

Running! Thanks for help! 👍

mn1aC commented

Now I need to look into belgium eID cards, don't know how to talk to them..