nickdesaulniers / node-nanomsg

Node.js binding for nanomsg
MIT License
402 stars 70 forks source link

load DLL fails in electron #196

Closed webbery closed 6 years ago

webbery commented 6 years ago

I install nanomsg by command npm install nanomsg in windows with vs2015. It builds a static library name nanomsg.lib. When I start electron, I meet an error looks like this:

A dynamic link library (DLL) initialization routine failed.
\\?\E:\workspace\logViewer\node_modules\nanomsg\build\Release\node_nanomsg.node
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:172:20)
    at Object.Module._extensions..node (module.js:671:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:172:20)
    at Module.load (module.js:561:32)
    at tryModuleLoad (module.js:504:12)
    at Function.Module._load (module.js:496:3)
    at Module.require (module.js:586:17)
    at require (internal/module.js:11:18)
    at bindings (E:\workspace\logViewer\node_modules\bindings\bindings.js:76:44)
    at Object.<anonymous> (E:\workspace\logViewer\node_modules\nanomsg\lib\index.js:1:195)

My electron version is 2.0.6. Because I can't google more info about that, so I don't know how to solve this problem. Any one help?

reqshark commented 6 years ago

i've had to change node's ABI version to match electron's since it plays around on a different 1

in order to get it to compile.

however, your error looks different than ABI mismatch. Let me investigate and get back on this.

nickdesaulniers commented 6 years ago

It builds a static library name nanomsg.lib

at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:172:20)

dlopen is for opening dynamic libraries, not static libraries. I think you need to create a .dll of this module, not a .lib file.

webbery commented 6 years ago

Yes, I see there is a static lib. But after I build a .dll with vs2015, the same error still appear.

reqshark commented 6 years ago

@webbery what version of node are you using?

reqshark commented 6 years ago

probably doesnt matter what version of node you're on,

let's try to trick npm's compiler into believing its building node bindings under a different ABI, just to get the binding's dl library to match the ABI version of electron's bindings.

can you try doing this command after you've got electron v2.0.7 and did npm install nanomsg:

npm rebuild --runtime=electron --target=2.0.7 --disturl=https://atom.io/download/atom-shell --abi=59

electron v2.0.7 should be happy with --abi=59 when the runtime is electron and that dist url

webbery commented 6 years ago

@reqshark Thanks for your help. It works.