Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling ruby script to C #1798

Closed
Sjeanpierre opened this issue Mar 4, 2014 · 5 comments
Closed

Compiling ruby script to C #1798

Sjeanpierre opened this issue Mar 4, 2014 · 5 comments

Comments

@Sjeanpierre
Copy link

I'm trying to follow this blog post from 2012 on compiling to C but ran into some issues.
http://blog.mruby.sh/201207020720.html

are there any current instructions on compiling a ruby script to C using mruby?

first I am running
mruby/bin/mrbc -Btest_symbol test_program.rb

When I run gcc -Imruby/src -Imruby/include -c test_program.c -o test_program.o i get the following error
test_program.c: In function ‘main’:
test_program.c:24: warning: implicit declaration of function ‘mrb_read_irep’
test_program.c:25: error: ‘mrb_state’ has no member named ‘irep’

here is the content of my test_program.c
db root vagrant-centos64_ ssh bash 15565

@take-cheeze
Copy link
Contributor

irep member is removed and now irep is like tree structure.
And you can load irep data with mrb_load_irep(mrb, test_symbol) now.

@Sjeanpierre
Copy link
Author

@take-cheeze can you point me towards a working example of code being compiled from a ruby script to c using mruby? This is my first time dealing with C directly and I am having issue getting this to work

@matz
Copy link
Member

matz commented Mar 4, 2014

Replace

int n = mrb_read_irep(mrb, test_symbol);
mrb_run(mrb, mrb_proc_new(mrb, mrb->irep[n], mrb_top_self(mrb));

with

mrb_load_irep(mrb, test_symbol);

@matz matz closed this as completed Mar 4, 2014
@carsonmcdonald
Copy link
Member

@Sjeanpierre I've actually thought about putting something simple together as an example so I did that real quick. Here is the repo with instructions https://github.com/carsonmcdonald/mruby-c-example

@Sjeanpierre
Copy link
Author

@matz @carsonmcdonald you guys are awesome, thanks for helping out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants