# Rice 1.2.0

**URL:** <https://www.ruby-forum.com/t/rice-1-2-0/177927>\
**Category:** Ruby\
**Created:** [October 26, 2009, 8:36pm UTC](https://www.ruby-forum.com/t/rice-1-2-0/177927 "2009-10-26T20:36:33Z")\
**Posts on this page:** 1\
**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:** [October 26, 2009, 8:36pm UTC](https://www.ruby-forum.com/t/rice-1-2-0/177927/1 "2009-10-26T20:36:33Z")

</div>

# Rice: Ruby Interface for C++ Extensions

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’s New?

- Rice::Director - Seemless Polymorphism across C++ and Ruby (named  
after  
SWIG\_Director)
- Default Arguments
- Removed explicit self requirement for global / module functions
- Various bug fixes

Supported Platforms:

- Linux
- Mac OS X 10.5 and 10.6

Windows support is iffy right now. Waiting to see how the mingw build  
of  
Ruby comes along.

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: [GitHub - jameskilton/rice: Account name changed!](http://github.com/jameskilton/rice)

Google G.: [http://groups.google.com/group/ruby-rice](http://groups.google.com/group/ruby-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\>  
#include \<rice/Constructor.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)
