# Compile architecture-specific, portable ruby

**URL:** <https://www.ruby-forum.com/t/compile-architecture-specific-portable-ruby/178238>\
**Category:** Ruby\
**Created:** [October 31, 2009, 2:15pm UTC](https://www.ruby-forum.com/t/compile-architecture-specific-portable-ruby/178238 "2009-10-31T14:15:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sean\_OSDonnell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b9e5f3/32.png) [@Sean\_OSDonnell](https://www.ruby-forum.com/u/Sean_OSDonnell)\
**Post date:** [October 31, 2009, 2:15pm UTC](https://www.ruby-forum.com/t/compile-architecture-specific-portable-ruby/178238/1 "2009-10-31T14:15:21Z")

</div>

Hello,

I am trying to put together a compiled, standalone version of ruby  
that I can drop into a user directory from a portable drive. Think:  
classroom setting with twenty, un-networked OSX 10.4/PPC machines. I  
want to compile once on one of these machines, then tarball it up and  
copy it out to the user’s home directory on each of the other  
computers. I then update the user’s PATH (e.g., /Users/student/local/  
ruby) to find this version of ruby.

Here’s how I build it now, which isn’t quite working:

ruby-1.87-src\> ./configure --prefix=/Users/teacher/local  
ruby-1.87-src\> make && make install

It’s built in my local directory, which I tarball and then copy out  
to /Users/student/local on the other PPCs. But, when I try to run it  
from the other computer, I get this error:

==start

dyld: lazy symbol binding failed: Symbol not found: \_ruby\_init\_stack  
Referenced from: /Applications/MKSAP15/RoR/Ruby/bin/ruby  
Expected in: /usr/lib/libruby.dylib

dyld: Symbol not found: \_ruby\_init\_stack  
Referenced from: /Applications/MKSAP15/RoR/Ruby/bin/ruby  
Expected in: /usr/lib/libruby.dylib

Trace/BPT trap

=end

Thoughts? I guess the high-level question is this: Are there  
additional flags that I need to pass to `configure` to build a self-  
contained, architecture-specific version?

Thanks,

Sean

---

<div class="post-metadata">

**Author:** ![Sean\_OSDonnell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b9e5f3/32.png) [@Sean\_OSDonnell](https://www.ruby-forum.com/u/Sean_OSDonnell)\
**Post date:** [October 31, 2009, 7:58pm UTC](https://www.ruby-forum.com/t/compile-architecture-specific-portable-ruby/178238/2 "2009-10-31T19:58:28Z")

</div>

On Sat, Oct 31, 2009 at 10:00:05PM +0900, Sean O’Donnell wrote:

> Here’s how I build it now, which isn’t quite working:  
> dyld: lazy symbol binding failed: Symbol not found: \_ruby\_init\_stack  
> Referenced from: /Applications/MKSAP15/RoR/Ruby/bin/ruby  
> Expected in: /usr/lib/libruby.dylib
> 
> dyld: Symbol not found: \_ruby\_init\_stack  
> Referenced from: /Applications/MKSAP15/RoR/Ruby/bin/ruby  
> Expected in: /usr/lib/libruby.dylib
> 
> Trace/BPT trap
> 
> =end

These are errors from the linker on the other PPC. When you built ruby  
it put the path to the shared library in the executable, and the file  
/usr/lib/libruby.dylib does not exist on the student’s machine.

> Thoughts? I guess the high-level question is this: Are there  
> additional flags that I need to pass to `configure` to build a self-  
> contained, architecture-specific version?

Built a fully staticly linked ruby instead. If you plan on using zlib  
or  
openssl in your teaching you’ll need to build them and put them in the  
tarball too.

Edit the ext/Setup file in the ruby distribution tarball to turn on the  
‘nodynamic’ option and uncomment each extension you would like compiled  
statically.

Then run :

```
./configure --disable-shared --prefix=/Users/student/local/ruby
make && make install

```

Then I believe you’ll be a step closer. Doing this will disable the  
dynamic loading of extensions, so I’m assuming that you will not later  
deploy gems with extensions on top of this.

enjoy,

-jeremy

---

<div class="post-metadata">

**Author:** ![Sean\_OSDonnell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b9e5f3/32.png) [@Sean\_OSDonnell](https://www.ruby-forum.com/u/Sean_OSDonnell)\
**Post date:** [October 31, 2009, 8:01pm UTC](https://www.ruby-forum.com/t/compile-architecture-specific-portable-ruby/178238/3 "2009-10-31T20:01:27Z")

</div>

Sean O’Donnell wrote:

> Hello,
> 
> I am trying to put together a compiled, standalone version of ruby  
> that I can drop into a user directory from a portable drive.  
> […]

Why not use JRuby?

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![Sean\_OSDonnell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b9e5f3/32.png) [@Sean\_OSDonnell](https://www.ruby-forum.com/u/Sean_OSDonnell)\
**Post date:** [October 31, 2009, 11:46pm UTC](https://www.ruby-forum.com/t/compile-architecture-specific-portable-ruby/178238/4 "2009-10-31T23:46:10Z")

</div>

On Oct 31, 2:55 pm, Jeremy H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > =end  
> > openssl in your teaching you’ll need to build them and put them in the
> 
> Jeremy H. removed\_email\_address@domain.invalid  
> Thanks - I may go this way. However, if I were to continue with a non-  
> static version, how would I force the path to point to the desired  
> shared library? Like this?

./configure --prefix=/Users/student/local --libdir=/Users/student/  
local

In the version I’ve built, I can see libruby.dylib in the /Users/  
student/local/lib directory. It was my intention to keep these shared  
libraries contained within the build. I guess the executable just  
wasn’t pointing to it.

I’m glad you mentioned that I cannot deploy w/extensions on top of the  
statically built ruby. I need to use sqlite3-ruby, which may fall into  
this category. Sounds like I’ve got some experimenting to do.

Thanks,  
Sean

---

<div class="post-metadata">

**Author:** ![Sean\_OSDonnell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b9e5f3/32.png) [@Sean\_OSDonnell](https://www.ruby-forum.com/u/Sean_OSDonnell)\
**Post date:** [November 1, 2009, 1:56am UTC](https://www.ruby-forum.com/t/compile-architecture-specific-portable-ruby/178238/5 "2009-11-01T01:56:07Z")

</div>

On Sun, Nov 01, 2009 at 07:40:13AM +0900, Sean O’Donnell wrote:

> > statically.  
> > Thanks - I may go this way. However, if I were to continue with a non-  
> > static version, how would I force the path to point to the desired  
> > shared library? Like this?
> 
> ./configure --prefix=/Users/student/local --libdir=/Users/student/  
> local

I think just doing:

```
./configure --prefix=/Users/student/local

```

will do the trick.

> In the version I’ve built, I can see libruby.dylib in the /Users/  
> student/local/lib directory. It was my intention to keep these shared  
> libraries contained within the build. I guess the executable just  
> wasn’t pointing to it.

Yup, that would be the case.

> I’m glad you mentioned that I cannot deploy w/extensions on top of the  
> statically built ruby. I need to use sqlite3-ruby, which may fall into  
> this category. Sounds like I’ve got some experimenting to do.

I think running this configure you’ll probably be okay. And you can  
prepare  
all the items you need for you students this way too. Go ahead and  
install  
the gems you need by executing the /Users/student/local/bin/gem command  
and they should all be installed relative to the /Users/student/local  
on you instructors machine, then you can tar up the  
/Users/studient/local  
dir for your students and distribute it.

And the other email in this thread mentions jruby, which is also an  
option,  
depending on the other gems you are planning on using.

enjoy,

-jeremy
