I’m updating a fairly old C extension bound to a ruby gem that I didn’t write. Currently, when I execute the script that will use the C extension, I get this error:
symbol lookup error: /path/to/lib.so: undefined symbol: rb_str2cstr
There was also problems with STR2CSTR in the same library, which was fixed by replacing it with StringValuePtr. My initial thought was to replace rb_str2cstr with rb_string_value_ptr, but when I try that, the C extension will not build. I’m by no means a C programmer, and am not sure where to go with this. I know I have to replace rb_str2cstr with its replacement, but I can’t seem to figure out what that is.
In the source of
ruby.hfor Ruby 1.8.7-p357 it has:StringValuereturns aVALUEthat you can useRSTRINGon to get the length andchar *pointer:So if the existing code looked something like this:
Then change it to:
If you’re sure that
stris already a Ruby String then you could omit theStringValuecall, but it’d be safer to keep it.