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

Error: A dynamic link library (DLL) initialization routine failed #167

Open
meischke opened this issue May 6, 2022 · 5 comments
Open

Error: A dynamic link library (DLL) initialization routine failed #167

meischke opened this issue May 6, 2022 · 5 comments

Comments

@meischke
Copy link

meischke commented May 6, 2022

Hi,

I want to use pkg to create a windows binary of my app including lmdb.

I'm a little bit lost and don't know how to fix the error.
Is this a config thing ? windows ? node ? pkg ? lmdb ?
Node 14.19.1 is installed and used by pkg.
I built the native node files using the commands in lmdb package.json.

pkg/prelude/bootstrap.js:1833
      throw error;
      ^
Error: A dynamic link library (DLL) initialization routine failed
C:\Users\xxxxxx\AppData\Local\Temp\pkg\ffc9b19bc2f52a93e9316025fa171e0b702d12bbd5781ad7c04c1dff7f471ea9\lmdb-win32-x64\node.abi83.node
    at process.dlopen (pkg/prelude/bootstrap.js:2212:28)
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1144:18)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at Module.require (pkg/prelude/bootstrap.js:1812:31)
    at require (internal/modules/cjs/helpers.js:101:18)
    at load (C:\snapshot\lmdbpkgtest\node_modules\node-gyp-build-optional-packages\index.js:21:10)
    at Object.<anonymous> (C:\snapshot\lmdbpkgtest\node_modules\lmdb\dist\index.cjs:47:64)
    at Module._compile (pkg/prelude/bootstrap.js:1887:22) {
  code: 'ERR_DLOPEN_FAILED'
}

index.js

const lmdb = require('lmdb')

package.json (with pkg config)

{
  "name": "lmdbpkgtest",
  "version": "1.0.0",
  "description": "",
  "main": "src/index.js",
  "bin": "src/index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "pkg": {
    "targets": [
      "node14-win-x64"
    ],
    "outputPath": "dist/",
    "assets": [
      "node_modules/lmdb-win32-x64/*"
    ]
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "lmdb": "^2.3.10"
  }
}
@kriszyp
Copy link
Owner

kriszyp commented May 6, 2022

I tried this out locally and getting the same error. And I have tried this with a stripped-down barebones native .node module, still get this error or Module did not self-register error, so am wondering if pkg really works consistently with native modules.

@meischke
Copy link
Author

meischke commented May 6, 2022

Thanks for the test
It's the first time for me that pkg does not work.

I have tried caxa now. My "Hello World" binary with lmdb runs error free on windows and linux.

@kriszyp
Copy link
Owner

kriszyp commented May 6, 2022

That's good to hear that you had some success. I think I have heard of people using nexe too (I haven't tried it).

I'd still be interested in figuring out the issue with pkg (and/or letting them know).

CMCDragonkai referenced this issue in MatrixAI/js-db May 10, 2022
kriszyp added a commit that referenced this issue May 10, 2022
@kriszyp
Copy link
Owner

kriszyp commented May 10, 2022

As it turns out, the issue was due the win_delay_load_hook: false flag. This is a rather cryptic bit of node-gyp configuration that I had thought was helpful for electron. I removed this line for now, which seems to fix this issue. But I will see if I can try this out with electron to see if it causes any regressions.

@kriszyp
Copy link
Owner

kriszyp commented May 10, 2022

Seems like electron loads fine with this flag removed.

kriszyp added a commit that referenced this issue May 18, 2022
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

2 participants