Search code examples
ruby64-bit32bit-64bitdynamic-libraryruby-llvm

Running 64bit dylib with 32bit ruby on Mac


I was trying to install ruby-llvm.

I could install llvm with brew install llvm -shared, and I also could install ruby-llvm with sudo gem install ruby-llvm command.

However, when I tried to run the examples, I got these error messages.

/Users/smcho/.rvm/gems/ruby-1.9.3-p194/gems/ffi-1.1.5/lib/ffi/library.rb:121:in `block in ffi_lib': 
Could not open library '/DIR/.rvm/gems/ruby-1.9.3-p194/gems/ruby-llvm-3.0.0/lib/libRubyLLVMSupport-3.0.0.dylib': 
dlopen(/DIR/.rvm/gems/ruby-1.9.3-p194/gems/ruby-llvm-3.0.0/lib/libRubyLLVMSupport-3.0.0.dylib, 5): no suitable image found.  Did find: (LoadError)
/DIR/.rvm/gems/ruby-1.9.3-p194/gems/ruby-llvm-3.0.0/lib/libRubyLLVMSupport-3.0.0.dylib: mach-o, but wrong architecture

I checked that the dynamic library is 64bit.

file /DIR/.rvm/gems/ruby-1.9.3-p194/gems/ruby-llvm-3.0.0/lib/libRubyLLVMSupport-3.0.0.dylib 
libRubyLLVMSupport-3.0.0.dylib: Mach-O 64-bit dynamically linked shared library x86_64

And it seems that ruby is running in 32bit mode. ruby 1.9.3p194 (2012-04-20 revision 35410) [i386-darwin11.4.0].

How can I resolve this issue? Is there a way to download 32bit version of ruby-llvm or 64bit version of ruby?


Solution

  • It seems like you've installed ruby in 32 bit mode. Would installing ruby in 64 bit mode solve the problem?

    To force 64 bit you could try the following with a recent version of RVM:

    $ rvm install 1.9.3 --64
    

    or $ rvm install 1.9.3 --with-arch=x86_64

    (from: http://www.engineyard.com/blog/2012/rvm-stable-and-more/)

    For compiling 32 bit mode ruby on OS X we have --32, --64 and --universal flags:

    $ rvm install 1.9.3 --universal # to build fat binary including both 32 and 64 bit binaries
    $ rvm install 1.8.7 --32 # to build only 32 bit ruby
    $ rvm install 1.8.7 --with-arch=i386 # is equivalent to the 32 bit one, but is available only via RVM, ruby 1.8.7 sources do not support it.