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

Incompatible with electron 4 and later? #129

Open
TanninOne opened this issue Apr 9, 2019 · 4 comments
Open

Incompatible with electron 4 and later? #129

TanninOne opened this issue Apr 9, 2019 · 4 comments

Comments

@TanninOne
Copy link

The operating system is Windows 10
I have a project that heavily relies on native libraries, some are based on nbind others use nan directly.
On electron 2 and 3 they all work, on electron 4 (tested 4.1.3) I can't get the nbind-based modules to load.

When I try to load nbind-based native modules they all produce an error message, either "Module did not self-register." or "The specified procedure could not be found."
I've debugged the second one and the error message from the api is "entry point not found".

Now I have a bit of an idea what's the trigger for this problem because starting with electron 4 they don't ship node.dll any more, that functionality is now apparently statically linked into electron.exe.
Still, with the same build settings I got all the non-nbind modules to load correctly so I was wondering in how far nbind might be playing into this.

@SpaceK33z
Copy link

I can reproduce this too with https://github.com/2bbb/node-abletonlink. It works perfectly fine on macOS, but on Windows crashes with "Module did not self-register."

@TanninOne
Copy link
Author

I think I found a fix, although I don't 100% understand it.

Merge this into your bindings.json

{
    "targets": [
        {
            "conditions": [
                [
                    'OS=="win"',
                    {
                        "libraries": [
                            "-DelayLoad:node.exe"
                        ],

So essentially adding the linker flag "/DelayLoad:node.exe".

This apparently allows electron.exe to take the place of node.exe when the native library loads symbols from it.
Why I don't have to do that for all the other native libraries I have no clue.

@SpaceK33z
Copy link

Thanks so much @TanninOne, this workaround worked!

@TanninOne
Copy link
Author

Another related thing I just found out and still don't fully understand:
I was getting crashes when using c++ streams in a nbind extension running in electron.

After quite a bit of bumbling about what seems to be causing it is that the c++ runtime functions are now also delay loaded and for reasons I don't know it seems to try and load those function from the electron.exe instead of the proper runtime dlls.

Only solution I have so far is forcing the runtime to be linked statically.

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