Search code examples
crubyruby-c-extension

Why am I able to directly use some of the ruby C extension array methods, but not others?


I am using many of the array methods found in array.c of the ruby codebase, but when trying to call

VALUE rIntersection = rb_ary_and(rAry1, rAry2); 

I got this error:

dyld: lazy symbol binding failed: Symbol not found: _rb_ary_and
  Referenced from: ./ext/ev/counters.bundle
  Expected in: flat namespace

In other areas of my code I am using rb_ary_sort_bang, rb_ary_clear, rb_ary_reverse, etc etc. So I'm not sure why rb_ary_and is any different.


Solution

  • Have a look at http://www.ruby-doc.org/doxygen/1.8.4/array_8c-source.html (Line 2666)

    There you can see that the method rb_ary_and is declared static. This means that it is only visible inside of array.c.