# Ruby Embedding

**URL:** <https://www.ruby-forum.com/t/ruby-embedding/164475>\
**Category:** Ruby\
**Created:** [April 1, 2009, 8:15pm UTC](https://www.ruby-forum.com/t/ruby-embedding/164475 "2009-04-01T20:15:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mperham](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e47c2d/32.png) [@mperham](https://www.ruby-forum.com/u/mperham)\
**Post date:** [April 1, 2009, 8:15pm UTC](https://www.ruby-forum.com/t/ruby-embedding/164475/1 "2009-04-01T20:15:20Z")

</div>

Hello everybody.

I downloaded the ruby 1.9.1 for windows and i’m trying to embed using  
C++ for 3 days and, i don’t know but for some reason i’m getting crashes  
with these functions:

…  
rb\_load\_file  
ruby\_incpush  
ruby\_options  
…

I searched for help but the documentation on ruby’s website is for 1.8.?  
and i can’t find anywhere a good documentation for 1.9.1. Thanks in  
advance.

---

<div class="post-metadata">

**Author:** ![mperham](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e47c2d/32.png) [@mperham](https://www.ruby-forum.com/u/mperham)\
**Post date:** [April 1, 2009, 8:56pm UTC](https://www.ruby-forum.com/t/ruby-embedding/164475/2 "2009-04-01T20:56:21Z")

</div>

Mike Piazza wrote:

> I downloaded the ruby 1.9.1 for windows and i’m trying to embed using  
> C++ for 3 days and, i don’t know but for some reason i’m getting crashes  
> with these functions:
> 
> …  
> rb\_load\_file

Post a sample of your code, and the “crash” particulars. And what C++  
are you using?

---

<div class="post-metadata">

**Author:** ![mperham](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e47c2d/32.png) [@mperham](https://www.ruby-forum.com/u/mperham)\
**Post date:** [April 1, 2009, 10:01pm UTC](https://www.ruby-forum.com/t/ruby-embedding/164475/3 "2009-04-01T22:01:31Z")

</div>

Phlip wrote:

> Mike Piazza wrote:
> 
> > I downloaded the ruby 1.9.1 for windows and i’m trying to embed using  
> > C++ for 3 days and, i don’t know but for some reason i’m getting crashes  
> > with these functions:
> > 
> > …  
> > rb\_load\_file
> 
> Post a sample of your code, and the “crash” particulars. And what C++  
> are you using?

I’m using MSVC 2008 Express

The code:

extern “C”  
{  
#include \<ruby.h\>  
}

#include   
#include \<conio.h\>

RUBY\_GLOBAL\_SETUP

int main(int argc, char \*\*argv)  
{  
RUBY\_INIT\_STACK

```
ruby_init();
ruby_init_loadpath();
ruby_script("embedded");

void *file = rb_load_file("test.rb");
ruby_run_node(file);

return 1;

```

}
