2

I know there's severals post about this, but i'm stack

here's my C code

#include </usr/include/ruby-1.9.1/ruby/ruby.h>#include <stdio.h>#include <stdlib.h>int main(){ ruby_init(); rb_eval_string("puts 'hello'"); ruby_finalize(); return 0; }

i've got the following error when compile it in sublime text 2

In file included from /Users/pierrebaille/Code/Ruby/embedRuby/embedRubyFirst.c:1:/usr/include/ruby-1.9.1/ruby/ruby.h:1481:24: error: ruby/subst.h: No such file or directory         [Finished in 0.1s with exit code 1]

thanks for your help

askedDec 10, 2012 at 8:43
szymanowski's user avatar
0

2 Answers2

6

You should not hard-code the full path of a header file like

#include </usr/include/ruby-1.9.1/ruby/ruby.h>

proper is

#include <ruby.h>

and told your gcc to search the header file via CFLAGS and libariy via LD_FLAGS, simply command without makefile could be:

gcc -o demo.exe -I/path/to/ruby/headers rubydemo.c -L/path/to/ruby/lib -lruby-libary-name

answeredDec 10, 2012 at 8:48
ray_linn's user avatar
Sign up to request clarification or add additional context in comments.

2 Comments

thank you, demo.exe? if i am on OSX i should use something else no? like demo.rbo maybe? sorry i'm a beginner. I think i should take time to learn more about gcc...
could be, I am not sure, no have OS-X in hand.
3

One of you files you're including in turn includesruby/subst.h, , but it appears thatruby is not in your path, which is why you have this in your code:

#include </usr/include/ruby-1.9.1/ruby/ruby.h>

Instead of hardcoding paths you should simply add "/some_path/" to your compiler path(s) setting, wheresome_path contains the folderruby as a child. Now your own include turns into:

#include <ruby/ruby.h>
answeredDec 10, 2012 at 8:45
Ed Swangren's user avatar

3 Comments

i don't know how to add path to my compiler... but i've moved the ruby 1.9.1 folder into my usr/include folder wich is, i think, in the compiler path. no?
when i just replace my hardcoded include with #include <ruby/ruby.h>
it give me this error: Undefined symbols for architecture x86_64: "_rb_eval_string", referenced from: _main in ccqmMJJ3.o "_ruby_finalize", referenced from: _main in ccqmMJJ3.o "_ruby_init", referenced from: _main in ccqmMJJ3.o ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status [Finished in 0.5s with exit code 1]

Your Answer

Sign up orlog in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

By clicking “Post Your Answer”, you agree to ourterms of service and acknowledge you have read ourprivacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.