Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dll could not be initialized in module.js #48

Closed
RichardFoss opened this issue Jul 4, 2017 · 10 comments
Closed

dll could not be initialized in module.js #48

RichardFoss opened this issue Jul 4, 2017 · 10 comments

Comments

@RichardFoss
Copy link

Hi,

I am using node v6.11.0 together with nw.js. I have installed cap successfully, and am now wanting to use it to send AVDECC ethernet packets. When I try to initialize with c = new Cap(); I get an error message indicating that a dll cannot be initialized in module.js.

I have used cap successfully on the Mac and am now porting the same code to Windows. I have Visual Studio 2015 enterprise edition installed.

Any idea what might be causing this run time message?

Thanks!

@RichardFoss
Copy link
Author

To be more explicit with the error message, it is:
Uncaught error: A dynamic link library (DLL) initialization routine failed module.js :640

@RichardFoss
Copy link
Author

Sorry, didn't mean to close this!!

@mscdex
Copy link
Owner

mscdex commented Jul 4, 2017

Sorry, I don't really have any experience with compiling addons for use with nw.js.

@RichardFoss
Copy link
Author

Thanks for the quick reply - I will see if I can initialize cap under Windows just from node.js. I didn't think that nw.js would be the problem. I used nw.js with cap on the Mac and it worked fine.

@mscdex
Copy link
Owner

mscdex commented Jul 4, 2017

IIRC nw.js has its own special method of compiling addons (using nw-gyp) in order to properly integrate with its bundled chrome/chromium (V8 really).

Using cap directly with node on Windows should definitely work fine though.

@RichardFoss
Copy link
Author

This all makes sense. I will try node and cap tomorrow. Thanks for the help!

@RichardFoss
Copy link
Author

Using cap directly with node on Windows does indeed take me beyond the 'require' statement where my error occurred. I do need the nw capabilities, and have posted the following on the nw.js site:

I have been successfully using the module cap in an osx node/nw program to receive and transmit Ethernet packets. I am porting the program to Windows, and have an issue with the cap module.

I am using node.js v6.11.0 and nw.js v0.23.5. Windows 8.1.

A problem arises at the statement:
var Cap = require('cap').Cap;
Where I get the following output:

module.js:640 Uncaught Error: A dynamic link library (DLL) initialization routine failed.
\?\D:\AVBFlexSDK\node_modules\cap\build\Release\cap.node
at Object.Module._extensions..node (module.js:640:18)
at Module.load (module.js:527:32)
at tryModuleLoad (module.js:490:12)
at Function.Module._load (module.js:482:3)
at Module.require (module.js:537:17)
at require (internal/module.js:11:18)
at Object. (D:\AVBFlexSDK\node_modules\cap\lib\Cap.js:3:13)
at Module._compile (module.js:593:30)
at Object.Module._extensions..js (module.js:610:10)
at Module.load (module.js:527:32)

The statement is not a problem within a node.js program, and the cap module installs fine (Python 2.7 and Visual C++ installed). I have done the following to resolve the issue:

  1. Given that I am using an LTS release, I first replaced the win_delay_load_hook.cc file with the one given on the nw.js documentation page. The require statement resulted in the same error message.
  2. I then followed the procedure for the non-LTS releases:
    set PYTHON=C:\Python27\python.exe
    set npm_config_target=0.23.5
    set npm_config_arch=x64
    set npm_config_runtime=node-webkit
    set npm_config_build_from_source=true
    set npm_config_node_gyp=C:\Users<my info>\AppData\Roaming\npm\node_modules
    Still the same result - an error at the require statement.

Possibly someone in this group has had a similar experience and resolved it - which would be wonderful!

@robsontenorio
Copy link

robsontenorio commented Jul 25, 2017

@RichardFoss Its just about "prebuild" the target package "cap" (https://www.npmjs.com/package/prebuild).
I use Electron, so "prebuild" provide a way to compile the package to the target OS/arch. You need to find some similar tool on NW.JS.

So, that issue has nothing to do with "cap", but the way packages are compiled to the target OS.

@RichardFoss
Copy link
Author

Thanks robsontenorio! I managed to resolve my issue and have meant to post my solution to the group in case anyone else has a similar dilemma. The steps I took are given below. Step d is the "similar tool" that you are referring to.

For native node modules (for example cap), you will:
a. First need to install all the required tools and configurations. To do this, you could use Microsoft's windows-build-tools using:
npm install --global --production windows-build-tools
from an elevated PowerShell or CMD.exe (run as Administrator). This will install Visual Studio and also Python 2.7.
b. On Windows, you need to replace the file
\node_modules\node-gyp\src\win_delay_load_hook.cc
with the one at
https://github.com/nwjs/nw.js/blob/nw18/tools/win_delay_load_hook.cc
before installing modules with node-gyp or npm.
c. Run the following command in your terminal to install nw-gyp globally:
npm install -g nw-gyp
d. If for example, cap is the native module, then in the node_modules/cap folder, run
nw-gyp rebuild --target=0.23.5(or whatever your version of nw.js is)
e. In your native module documentation, look for any programming guidelines that are unique to Windows. For example in cap:
setMinBytes(< integer >nBytes) - (void) - (Windows ONLY) This sets the minimum number of packet bytes that must be captured before the full packet data is made available.

@mscdex
Copy link
Owner

mscdex commented Jul 25, 2017

Thanks for the information @robsontenorio and @RichardFoss

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants