# Rice-1.1.0 with Ruby 1.9.0 compatibility!

**URL:** <https://www.ruby-forum.com/t/rice-1-1-0-with-ruby-1-9-0-compatibility/166579>\
**Category:** Ruby\
**Created:** [April 27, 2009, 4:07pm UTC](https://www.ruby-forum.com/t/rice-1-1-0-with-ruby-1-9-0-compatibility/166579 "2009-04-27T16:07:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jruyle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@jruyle](https://www.ruby-forum.com/u/jruyle)\
**Post date:** [April 27, 2009, 4:07pm UTC](https://www.ruby-forum.com/t/rice-1-1-0-with-ruby-1-9-0-compatibility/166579/1 "2009-04-27T16:07:28Z")

</div>

# Rice: Ruby Interface for C++ Extensions

Change Log:

- Works on Ruby 1.8.6, 1.8.7 and 1.9.0 with no changes to current  
extensions
- Fixed memory leaks
- Fixed various compilation issues, build uses the system’s ruby  
library and doesn’t assume the name of libruby.so
- Now properly uses the ruby in --with-ruby for every step of the  
compilation process (e.g. can be installed on multiple ruby installs  
on a single system)
- Removed all uses of known deprecated APIs, like STR2CSTR
- Now builds extensions to allow multiple Rice extensions to be  
require’d together

What is Rice?

Rice is a C++ interface to Ruby’s C API. It provides a type-safe and  
exception-safe interface in order to make embedding Ruby and writing  
Ruby extensions with C++ easier. It is similar to Boost.Python in many  
ways, but also attempts to provide an object-oriented interface to all  
of the Ruby C API.

What Rice gives you:

- A simple C+±based syntax for wrapping and defining classes
- Automatic conversion of exceptions between C++ and Ruby
- Smart pointers for handling garbage collection
- Wrappers for most builtin types to simplify calling code

Documentation: [http://rice.rubyforge.org](http://rice.rubyforge.org)  
Project Page: [http://rubyforge.org/projects/rice](http://rubyforge.org/projects/rice)

How do you get Rice?

gem install rice

Note: Rice does require a C++ compiler. See the Documentation page for  
more details.

How simple of a syntax?

wrapper.cpp

#include “rice/Class.hpp”

class MyWrapper {  
public:  
MyWrapper() { }

void doThis() { }  
int doThat(int a, float b) { }  
};

extern “C”  
void Init\_wrapper()  
{  
define\_class(“MyWrapper”)  
.define\_constructor(Constructor())  
.define\_method(“do\_this”, &MyWrapper::doThis)  
.define\_method(“do\_that”, &MyWrapper::doThat);  
}

extconf.rb

require ‘mkmf-rice’  
create\_makefile(“wrapper”)

test.rb

require ‘wrapper’  
c = MyWrapper.new  
c.do\_this  
c.do\_that(1, 2.0)

Building Ruby wrapper extensions have never been so easy!

---

<div class="post-metadata">

**Author:** ![jruyle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@jruyle](https://www.ruby-forum.com/u/jruyle)\
**Post date:** [April 27, 2009, 4:40pm UTC](https://www.ruby-forum.com/t/rice-1-1-0-with-ruby-1-9-0-compatibility/166579/2 "2009-04-27T16:40:23Z")

</div>

On Mon, Apr 27, 2009 at 10:06 AM, Jason R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> # Rice: Ruby Interface for C++ Extensions
> 
> Change Log:
> 
> - Works on Ruby 1.8.6, 1.8.7 and 1.9.0 with no changes to current extensions

Do you mean 1.9.1?

(1.9.0 was an unstable developer snapshot)

-greg

---

<div class="post-metadata">

**Author:** ![jruyle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@jruyle](https://www.ruby-forum.com/u/jruyle)\
**Post date:** [April 27, 2009, 5:27pm UTC](https://www.ruby-forum.com/t/rice-1-1-0-with-ruby-1-9-0-compatibility/166579/3 "2009-04-27T17:27:25Z")

</div>

On Mon, Apr 27, 2009 at 10:39 AM, Gregory B.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> (1.9.0 was an unstable developer snapshot)
> 
> -greg

Crap, I knew I was missing something. I had somehow got my mind  
switched from 1.9.1 to 1.9.0 and have tested against that older  
version. Unfortunately right now, Rice does _not_ run properly against  
1.9.1, there’s something with the exception handling that I can’t  
figure out that causes segfaults. This looks to be “fixed” in trunk,  
but that’s not going to be out for a while (I’ve heard even well into  
next year).

So I guess I misspoke a bit here, Rice is not fully 1.9 compatible,  
though hopefully this issue can be figured out and fixed soon. When it  
does I’ll get another release out.

Jason

---

<div class="post-metadata">

**Author:** ![jruyle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@jruyle](https://www.ruby-forum.com/u/jruyle)\
**Post date:** [April 27, 2009, 5:35pm UTC](https://www.ruby-forum.com/t/rice-1-1-0-with-ruby-1-9-0-compatibility/166579/4 "2009-04-27T17:35:04Z")

</div>

HA, he gotcha there Jason!

Congrats on the release.

/Shawn
