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

electron + windows issue; aka win_delay_load_hook issue #17

Closed
usagi opened this issue Apr 27, 2020 · 9 comments · Fixed by #63
Closed

electron + windows issue; aka win_delay_load_hook issue #17

usagi opened this issue Apr 27, 2020 · 9 comments · Fixed by #63
Assignees
Labels

Comments

@usagi
Copy link
Contributor

usagi commented Apr 27, 2020

Issue

It will be happen if we want to use electron with node-bindgen on Windows:

error: linking with `link.exe` failed: exit code: 1181
  |
(...abbr...)
  = note: LINK : fatal error LNK1181: cannot open input file 'win_delay_load_hook.obj'

Reference

Coping method in neon

Note

Using dherman/electron-build-env makes it easy to prepare a workspace for repro.

  1. In the ./native directory, prepare a cdylib project use node-bindgen.
  2. In the ./ directory, prepare a package.json with electron-build-env and nj-cli in the devDependencies. And prepare "electron-build-env nj-cli build" in scripts such as experiment0.
  3. Run yarn experiment0.
@timfish
Copy link

timfish commented Jul 14, 2020

Was this already fixed here?

@sehz
Copy link
Collaborator

sehz commented Jul 14, 2020

@usagi Is the bug still there?

@usagi
Copy link
Contributor Author

usagi commented Jul 14, 2020

// Wait a minutes please, I'll test in my Windows machine, and then report current status.

@usagi
Copy link
Contributor Author

usagi commented Jul 14, 2020

Unfortunatelly, I cannot try to the testing because #46 is blocking.

@sehz
Copy link
Collaborator

sehz commented Jul 27, 2020

Can you try this again now since #46 is resolved?

@usagi
Copy link
Contributor Author

usagi commented Jul 27, 2020

// Wait a days please, I'll make a time.

@usagi
Copy link
Contributor Author

usagi commented Jul 28, 2020

Sadly, this issue is not solved yet.

Repro:

  1. Prepare a project using node-bindgen ( In easily, just use the example/function project )
  2. Run yarn init && yarn add electron && yarn add electron-build-env nj-cli -D in the project root dir.
  3. Run yarn electron-build-env nj-cli build.
  = note: "C:\\(...abbr...)\link.exe" "/NOLOGO" (...abbr...) "userenv.lib" "msvcrt.lib" "win_delay_load_hook.obj" "delayimp.lib" "/DELAYLOAD:node.exe"
  = note: LINK : fatal error LNK1181: cannot open input file 'win_delay_load_hook.obj'

The full log: https://gist.github.com/usagi/659dd478c0eda47297bcebc10ff9e1fe

Reason why?:

Hints: neon's case

$ git clone git@github.com:neon-bindings/neon.git
$ cd neon
$ ack "node-gyp" ## or `grep`
[master]
appveyor.yml
35:  # Workaround until https://github.com/nodejs/node-gyp/issues/1933 is fixed.

crates/neon-sys/build.rs
32:        // 2. Build the object file from source using node-gyp.
92:    // The node-gyp build output includes platform information in a string
102:    // The node-gyp output includes the root directory of shared resources
105:    //     '-Dnode_root_dir=C:\\Users\\dherman\\.node-gyp\\8.3.0'
111:            .expect("Couldn't find node_root_dir in node-gyp output.");
116:    // The node-gyp output includes the name of the shared Node library file.
124:    //     '-Dnode_lib_file=C:\\Users\\dherman\\.node-gyp\\8.3.0\\<(target_arch)\\node.lib'
133:            .expect("Couldn't find node_lib_file in node-gyp output.");
140:            // Downcase all the npm environment variables to ensure they are read by node-gyp.
152:        // Run `node-gyp configure` in verbose mode to read node_root_dir on Windows.
156:            .expect("Failed to run \"node-gyp configure\" for neon-sys!");
160:                "Failed to run \"node-gyp configure\" for neon-sys!\n Out: {}\n Err: {}",
172:        // Run `node-gyp build`.
177:            .expect("Failed to run \"node-gyp build\" for neon-sys!");

crates/neon-sys/native/package-lock.json
400:    "node-gyp": {
402:      "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-3.6.2.tgz",

crates/neon-sys/native/package.json
4:    "preinstall": "echo 'Skipping node-gyp installation as part of npm install.'",
5:    "configure-release": "node-gyp configure --verbose",
6:    "configure-debug": "node-gyp configure --verbose --debug",
7:    "build-release": "node-gyp build --verbose",
8:    "build-debug": "node-gyp build --verbose --debug"
12:    "node-gyp": "^3.5.0",

RELEASES.md
15:* Workaround for nodejs/node-gyp#1933

What's the win_delay_load_hook.obj?

Appendix: Run the app with Electron if it solved

  1. yarn electron-build-env nj-cli build ( -> succeeded )
  2. Add index.html, index.js, preload.js
  3. yarn electron .

@sehz
Copy link
Collaborator

sehz commented Jul 29, 2020

Thanks for detailed explanation.

@usagi
Copy link
Contributor Author

usagi commented Aug 6, 2020

For early testers information: This issue is fixed with #63 + #67 ( ⛙ 4b15241 ), thus we can test it with below just now temporary:

[build-dependencies]
node-bindgen = { git = "https://github.com/infinyon/node-bindgen", rev="4b15241fd5b7e6789bbca06a2698ba1a6440459e", features = ["build"] }

[dependencies]
node-bindgen = { git = "https://github.com/infinyon/node-bindgen", rev="4b15241fd5b7e6789bbca06a2698ba1a6440459e" }

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

Successfully merging a pull request may close this issue.

4 participants