I’m trying to embed an interpreter in a DirectX project, so I’m using
MSVC. I grabbed the Ruby 1.9.3 source and compiled it with MSVC’s nmake
The make runs and ‘nmake test’ reports no problems. I then ‘nmake
install’ and the installed version seems to run acceptably. So I grab
the necessary files to embed and throw them into my project. I can
compile, but running the program gives nothing but segfaults.
Attached is a complete (very complete) explanation of the process I’m
using to create my segfault producer. Here’s the C code of the project
itself (this is just what I’m using to test embedding before I try
putting Ruby into the main project):
If I build this in release mode and run it from the prompt I get a
detailed segfault message from Ruby. If I build in debug mode I just
get a ‘standard’ windows crash. The text of the Ruby error message is
at the bottom of the attached file.
So my question is basically, “What am I doing wrong here?”
I’m guessing it’s either something I’m not reconfiguring in MSVC or else
it’s just that my embed code is incorrect. Possibly there’s something
going wrong in the build of the lib file. Either way I’m running out
of hair to pull out. I’m working on this at home and the internet there
is on the blink, so I have to go elsewhere to get online and look for
solutions. Please help. Your advice may be the only thing that saves
what’s left of my hair.
I’ll give it another go round with those, but I think I tried that
before. If I remember correctly I had some kind of compiler problems
with RUBY_INIT_STACK. All of the embedding discussions I’ve seen poking
around google didn’t mention it so I figured it wasn’t used in
embedding. Anyway, I’ll try messing with that again. Thank you.
Any further advice would be welcome, as I mentioned I have to collect
this information and then go back home and tinker with it away from the
internet, so I’d really like to get as much advice as possible before
returning to the secret-lab/stinky-bachelor-pad.
ruby_sysinit() was what I needed. When I had tried it before I had
thought that it wasn’t working because when I ran the compiled exe from
the shell it seemed to be freezing. It wasn’t freezing, it was just
that I had provided no arguments so it had gone into line-by-line mode
just like it was supposed to.
My mastery of idiocy is nearly complete. bows deeply
Anyway, if anyone is out there who’s looking to embed Ruby 1.9.3 in
Visual C++ 2008 the file attached to this post contains my main.cpp,
which shows how I’m doing it.
Thank you everyone for your help. Now that I’ve got the interpreter
running I can seek out and explore new and more interesting problems and
errors! Seriously though, this has been the sticking point in the
project for a long time now and now it’s working. I’ve been coding like
mad the past few days and several of my core modules are already up and
running. Thank you!
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.