silverhammermba / emberb

A guide to Ruby's C API
http://silverhammermba.github.io/emberb
Creative Commons Attribution 4.0 International
210 stars 25 forks source link

`ruby_options` no longer optional in 3.2? #27

Open silverhammermba opened 7 months ago

silverhammermba commented 7 months ago

According to this SO question, just calling ruby_init no longer works in Ruby 3.2 and you have to call ruby_options prior to setting the load path.

Figure out why that is and update the instructions for running Ruby in C.

artyomb commented 1 month ago

Hello, Works for me 3.3.1

#include <ruby.h>
int main(int argc, char **argv) {
    ruby_init();
    rb_eval_string("puts 'Hello from eval'");
    return ruby_cleanup(0);
}
gcc main.c -o ruby_in_c -I/home/user/.rbenv/versions/3.3.1/include/ruby-3.3.0 \
                        -I/home/user/.rbenv/versions/3.3.1/include/ruby-3.3.0/x86_64-linux \
                        -L/home/user/.rbenv/versions/3.3.1/lib\
                        -lruby