etscrivner / rbsecp256k1

Compiled Ruby wrapper around libsecp256k1 for secp256k1 ECDSA.
The Unlicense
19 stars 13 forks source link

Apple Silicon: Symbol not found: ___gmpn_set_str #54

Closed chainoperator closed 2 years ago

chainoperator commented 2 years ago

When trying to initialize rbsecp256k1 with context = Secp256k1::Context.create, I'm getting this error:

dyld: lazy symbol binding failed: Symbol not found: ___gmpn_set_str
  Referenced from: /Users/johnomar/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rbsecp256k1-5.0.1/ext/rbsecp256k1/rbsecp256k1.bundle
  Expected in: flat namespace

I've made sure to install (and reinstall) the required brew formulae:

brew install openssl libtool pkg-config gmp libffi

CleanShot 2021-11-30 at 20 10 30@2x

Looks like GMP is the culprit.

Not sure if I'm missing something or if rbsecp256k1 does not yet work on Apple Silicon? Any help would be appreciated.

etscrivner commented 2 years ago

Hi there! Thank you for the bug report.

I tried but was unable to reproduce this on macOS 11.6.1, Ruby v3.0.0 not on Apple Silicon and unfortunately I don't have access to Apple Silicon atm. I was able to find an almost identical issue on Linux but it looks like that fix is already incorporated.

This might be a silly question but have you tried uninstalling and reinstalling the gem? I'm wondering if perhaps there's been some drift with the dynamic libraries since it was first installed.

chainoperator commented 2 years ago

Hi! Thanks for your response.

I did uninstall and reinstall the gem. I also tried installing with gem install rbsecp256k1 -- --with-system-libraries without any luck.

As a final test, I got a friend with the latest m1 mac to try it. Same error as me :(

chainoperator commented 2 years ago

Upgrading the secp256k1 from bitcoin core fixed the issue! Here's a PR: https://github.com/etscrivner/rbsecp256k1/pull/55

Let me know if you need additional changes before accepting the PR.

etscrivner commented 2 years ago

Thanks! I've cut a new release (rbsecp256k1 v5.1.0) that incorporates this and other fixes. See release notes here: https://github.com/etscrivner/rbsecp256k1/releases/tag/v5.1.0

Please upgrade whenever you can and double check that this fixes your issue.

chainoperator commented 2 years ago

Thank you! Works like a charm.