I am trying to embed Ruby within a Visual C++ project, but I am having
trouble loading my script file.
How do I tell the Ruby interpreter where to look for my script file?
If I use ruby_options(), then my program hangs. So, I am trying to
pass the “-S” flag to Ruby, and I have set RUBYPATH to the directory
where “test.rb” lives.
Note: I am able to load the script if I put the script in the same
directory as my source files (which isn’t the same directory as the
built C++ .exe). I do not understand why this works. Ideally, I would
like to tell the Ruby interpreter where to find my “test.rb” script.
How do I do this? Thanks in advance for your help.
Here is a code snippet:
char *rargv, rarg1[MAX_PATH]
rargv = “ruby”;
rargv = rarg1;
NtInitialize(&rargc, (char ***)&rargv);
rb_load_protect(rb_str_new2(“test.rb”), Qfalse, &state);