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

failed to dlopen .node when embedding node.js in Windows C++ program #47682

Closed
zombieyang opened this issue Apr 23, 2023 · 2 comments
Closed
Labels
addons Issues and PRs related to native addons. question Issues that look for answers. windows Issues and PRs related to the Windows platform.

Comments

@zombieyang
Copy link

zombieyang commented Apr 23, 2023

Version

16.16.0

Platform

Windows

Subsystem

No response

What steps will reproduce the bug?

First, compile Node.js via vcbuild.bat dll, link the libnode.lib libnode.dll in a c++ program.
Then, load .node with such asprocess.dlopen(mod, 'xxx\\node_modules\\sqlite3\\lib\\binding\\napi-v6-win32-unknown-x64\\node_sqlite3.node.
or using require('sqlite3') will be the same.

How often does it reproduce? Is there a required condition?

100%

What is the expected behavior? Why is that the expected behavior?

can load the .node

What do you see instead?

Error Procedure not found is thrown.

different node addon will throw this error in different position
sqlite3 will throw the error in LoadLibraryExW
a hello world addon (written it following doc) will throw the error in DloadAcquireSectionWriteAccess

Additional information

  • If I compile node.js to a exe, all the code and configure are the same. No error will be thrown in .node loading.
  • If I embed node.js in a macos C++ program. No error will be thrown in .node loading.
  • I confirm that the node version of my node.js source code for compiling the libnode.dll, and the node version for doing node-gyp install are the same.
@bnoordhuis
Copy link
Member

See https://github.com/nodejs/node-gyp/blob/02480f6b6894a6bb81dd3e1365bc4df6d5336f7c/src/win_delay_load_hook.cc - it's something you need to fix on your end because it's a quirk of DLL loading that's not under node's control.

If you renamed your executable to node.exe, it should work again without additional steps. Good luck.

@bnoordhuis bnoordhuis closed this as not planned Won't fix, can't repro, duplicate, stale Apr 23, 2023
@bnoordhuis bnoordhuis added question Issues that look for answers. windows Issues and PRs related to the Windows platform. addons Issues and PRs related to native addons. labels Apr 23, 2023
@zombieyang
Copy link
Author

thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addons Issues and PRs related to native addons. question Issues that look for answers. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

No branches or pull requests

2 participants