views:

41

answers:

2

I have a ruby gem that I developed with ruby 1.9, and it works. With ruby 1.8, though, it says this when I try to run it:

dyld: lazy symbol binding failed: Symbol not found: _RBIGNUM_SIGN
  Referenced from: /Users/Adrian/Desktop/num_to_bytes/ext/num_to_bytes/num_to_bytes.bundle
  Expected in: flat namespace

dyld: Symbol not found: _RBIGNUM_SIGN
  Referenced from: /Users/Adrian/Desktop/num_to_bytes/ext/num_to_bytes/num_to_bytes.bundle
  Expected in: flat namespace

Trace/BPT trap

If I comment out the line that uses RBIGNUM_SIGN, it complains about other functions like rb_big_modulo. Some things work, like NUM2LONG. Here are some things I have tried:

  • In http://github.com/ruby/ruby/blob/ruby_1_8_7/ruby.h, RBIGNUM_SIGN is defined. But in all versions of ruby I have tried, it is not there.
  • I guessed that maybe it was defined in a different .h file. Knowing that Hpricot works with 1.8, I looked at http://github.com/hpricot/hpricot/blob/master/ext/hpricot_scan/hpricot_scan.h. It doesn't include any other files that #define it.
  • Putting things like extern VALUE rb_big_modulo(VALUE x); at the beginning of my extension don't help.
  • Using a brand new Ubuntu installation, I apt-getted ruby, tried to install the gem, and it didn't work either.
  • Putting have_library 'ruby', 'rb_big_modulo' in my extconf.rb didn't work.

As you can probably see, I am getting desperate (after weeks of trying things!). So, how can I get this to work?

Here is the gem: http://rubygems.org/gems/num_to_bytes

Here is the source: http://gist.github.com/404584

A: 

You could try requiring the backports gem. This provides some of the functionality of newer ruby versions for older ruby interpreters.

Steve Weet
That is written in ruby. I am trying to make a C extension.
Adrian
A: 
  • For RBIGNUM_SIGN, define it again in the source.
  • For rb_big_modulo(x, y), use rb_funcall(x, '%', 1, y).
Adrian