# Dylib or Bundle on OS X?

**URL:** <https://www.ruby-forum.com/t/dylib-or-bundle-on-os-x/108595>\
**Category:** Ruby\
**Created:** [July 5, 2007, 7:10am UTC](https://www.ruby-forum.com/t/dylib-or-bundle-on-os-x/108595 "2007-07-05T07:10:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sjml](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b19c9b/32.png) [@sjml](https://www.ruby-forum.com/u/sjml)\
**Post date:** [July 5, 2007, 7:10am UTC](https://www.ruby-forum.com/t/dylib-or-bundle-on-os-x/108595/1 "2007-07-05T07:10:00Z")

</div>

Background: I’m trying to embed a Ruby interpreter in my C++  
application. (I know, join the club, right?) My query to (and helpful  
response from) the SWIG user list is here:  
[http://www.nabble.com/Embedded-interpreter-with-shared-objects-tf4026656.html](http://www.nabble.com/Embedded-interpreter-with-shared-objects-tf4026656.html)  
(there’s some sample code there as well)

In short, I’ve got a singleton in C++ which I’m trying to reflect out  
into Ruby. The problem is that the Ruby interpreter loads up a second  
copy of the library so that the singleton isn’t properly shared across  
C++ and Ruby. The SWIG list recommended splitting off the wrapped  
classes into their own dynamic library that both the executable and the  
Ruby module can include.

I’m not sure, though, how to bind the code up in such a way that both an  
OS X application and Ruby would be happy working with it. Ruby wants a  
bundle, and my attempts to link the dylib into a bundle have just  
yielded bad memory access when I try and require it.

Can anyone offer some insight on the best way to accomplish this? Should  
I be looking at Frameworks or some other tech instead, or is there a  
good way to set up a bundle that references a dylib so that Ruby can  
load it as a module?
