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

Symbol not found #3590

Closed
phhoef opened this issue Jan 7, 2019 · 9 comments
Closed

Symbol not found #3590

phhoef opened this issue Jan 7, 2019 · 9 comments

Comments

@phhoef
Copy link

phhoef commented Jan 7, 2019

  • Version:
    "electron-builder": "^20.38.4"
  • Target:
    macOS & Windows x64

I am writing a small app that utilises serialport as dependency (which itself has native dependencies).
When starting the app in dev mode (npm-run-all --parallel bundle serve) everything is working fine. I am using electron-rebuild as postinstall script to compile the native dependencies for the used Electron (4.0.0) version.
When building the app for production issuing yarn build && electron-builder build --publish never, I cannot start the app bundle with the following error in the macOS log:

Dyld Error Message:
  Symbol not found: __ZN2v816FunctionTemplate3NewEPNS_7IsolateEPFvRKNS_20FunctionCallbackInfoINS_5ValueEEEENS_5LocalIS4_EENSA_INS_9SignatureEEEiNS_19ConstructorBehaviorE
  Referenced from: /var/folders/*/.com.my.app.a9yuVC
  Expected in: flat namespace

After I have tried building the app, I am no longer able to start the app in dev mode with the shown command.
This error is shown when starting the app in dev mode:

dyld: lazy symbol binding failed: Symbol not found: __ZN2v816FunctionTemplate3NewEPNS_7IsolateEPFvRKNS_20FunctionCallbackInfoINS_5ValueEEEENS_5LocalIS4_EENSA_INS_9SignatureEEEiNS_19ConstructorBehaviorE
  Referenced from: /Client/node_modules/@serialport/bindings/build/Release/bindings.node
  Expected in: flat namespace

dyld: Symbol not found: __ZN2v816FunctionTemplate3NewEPNS_7IsolateEPFvRKNS_20FunctionCallbackInfoINS_5ValueEEEENS_5LocalIS4_EENSA_INS_9SignatureEEEiNS_19ConstructorBehaviorE
  Referenced from: /Client/node_modules/@serialport/bindings/build/Release/bindings.node
  Expected in: flat namespace

I have to run $(npm bin)/electron-builder install-app-deps first, only after that I can start the app in dev mode again.
Running ($npm bin)/electron-rebuild does not work for some reason.

It seems, that this is an issue with the packaging.
I am quite new to all the electron, nodejs stuff so I do not think this is a bug. Probably my configuration is wrong.
Could anyone please help me out?


EDIT:
I've created a small test application to reproduce the issue.
Maybe it's helpful. https://github.com/phhoef/serialport-test

@benoist
Copy link

benoist commented Jan 7, 2019

I'm seeing the same issue.

I have the "postinstall": "electron-builder install-app-deps", added to my package.json

After running yarn I see

$ electron-builder install-app-deps
  • electron-builder version=20.38.4
  • loaded configuration file=package.json ("build" field)
  • rebuilding native production dependencies platform=darwin arch=x64
  • rebuilding native dependency name=fsevents
  • rebuilding native dependency name=keytar
✨  Done in 8.07s.

Then when I start I get this message:

$ webpack-dev-server --hot --host 0.0.0.0 --config=./webpack.dev.config.js --mode development
ℹ 「wds」: Project is running at http://0.0.0.0:8080/
ℹ 「wds」: webpack output is served from /
ℹ 「wds」: Content not from webpack is served from ..redacted../dist
ℹ 「wds」: 404s will fallback to /index.html
dyld: lazy symbol binding failed: Symbol not found: __ZN2v816FunctionTemplate3NewEPNS_7IsolateEPFvRKNS_20FunctionCallbackInfoINS_5ValueEEEENS_5LocalIS4_EENSA_INS_9SignatureEEEiNS_19ConstructorBehaviorE
  Referenced from: ..redacted../node_modules/keytar/build/Release/keytar.node
  Expected in: flat namespace

dyld: Symbol not found: __ZN2v816FunctionTemplate3NewEPNS_7IsolateEPFvRKNS_20FunctionCallbackInfoINS_5ValueEEEENS_5LocalIS4_EENSA_INS_9SignatureEEEiNS_19ConstructorBehaviorE
  Referenced from: ..redacted../node_modules/keytar/build/Release/keytar.node
  Expected in: flat namespace

✨  Done in 1.57s.

When I run $(npm bin)/electron-builder install-app-deps I see:

  • electron-builder version=20.38.4
  • loaded configuration file=package.json ("build" field)
  • rebuilding native production dependencies platform=darwin arch=x64

And after that the app starts normally.

When I try to release the app, it runs the install-app-deps again as it did with the postinstall
And this causes the same crash in the release version.

    "electron": "^4.0.1",
    "electron-builder": "^20.38.4",

@benoist
Copy link

benoist commented Jan 7, 2019

I noticed something else as well
After yarn install this is the contents of the keytar build folder

image

After $(npm bin)/electron-builder install-app-deps
This is the result of the build folder

image

@rvanmil
Copy link

rvanmil commented Jan 8, 2019

Same issue here using the keytar (4.3.0) dependency.

@gniezen
Copy link
Contributor

gniezen commented Jan 9, 2019

This may be due to an issue where the ABI for both Electron v3 and v4 is 64, but the builds are not compatible: electron/node-abi#55

@phhoef
Copy link
Author

phhoef commented Jan 9, 2019

@gniezen, thanks for your help.
Honestly, I do not completely understand the cause as I am quite new to Electron/Node.js.

I looked over your linked ticket, but didn't see a solution.
I executed $(npm bin)/electron --abi in the project root. The result is 64.

iMac:Client ph$ $(npm bin)/electron --abi
64

As far as I know, serialport does not have prebuilt binaries for Electron 4 (but for 3).
The issue is, that due to mixing up the version numbers, Electron is using the wrong prebuilt binaries, right?

Is there anything I can do about?
I also do not understand, why it is working when running electron-builder install-app-deps. This command re-compiles the native binaries for the right Electron version?
But why is it not possible to add this command to my package script?

@gniezen
Copy link
Contributor

gniezen commented Jan 9, 2019

@phhoef Have you tried downgrading your serialport to 6.2.2? v7 doesn't seem to work on macOS and Linux in any case: serialport/node-serialport#1770

Yes, it's also my understanding that due to them using the same ABI, Electron v4 tries to use the prebuilt binaries made for Electron v3. The only solutions I see at this stage:

  • Downgrade serialport to v6
  • Force all native dependencies to build from source (you may be able to do this using buildDependenciesFromSource=true in your electron-builder config)
  • Use Electron v3

@phhoef
Copy link
Author

phhoef commented Jan 9, 2019

I just saw, that there is a new version of serialport@7.1.2.
I changed the package.json and run yarn install.
Now, the problem seems to be fixed. I don't know if it's really the new version or anything related to the prebuilt binaries.
Anyhow, when executing the script yarn package I am able to open the App.

@phhoef phhoef closed this as completed Jan 9, 2019
@benoist
Copy link

benoist commented Jan 9, 2019

@phhoef I still have the problem we keytar...

@gniezen
Copy link
Contributor

gniezen commented Jan 9, 2019

@benoist I downgraded keytar to v4.2.1 as a workaround.

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

4 participants