Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby 1.8.7: Symbol not found Error

Just did a fresh install of ruby 1.8.7 REE and MRI on a machine with fresh gem sets (Using RVM) Yet in each of them when I try to use memprof i get this error

$ gem install memprof
$ irb
>> require 'rubygems'
>> require 'memprof'
>> LoadError: dlopen(/Users/schneems/.rvm/gems/ruby-1.8.7-p352@test/gems/memprof-0.3.10/lib/memprof.bundle, 9): Symbol not found: __mh_bundle_header
  Referenced from: /Users/schneems/.rvm/gems/ruby-1.8.7-p352@test/gems/memprof-0.3.10/lib/memprof.bundle
  Expected in: flat namespace
 in /Users/schneems/.rvm/gems/ruby-1.8.7-p352@test/gems/memprof-0.3.10/lib/memprof.bundle - /Users/schneems/.rvm/gems/ruby-1.8.7-p352@test/gems/memprof-0.3.10/lib/memprof.bundle
    from /Users/schneems/.rvm/gems/ruby-1.8.7-p352@test/gems/memprof-0.3.10/lib/memprof.bundle
    from /Users/schneems/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:59:in `require'
    from (irb):2

The error is Symbol not found: __mh_bundle_header. My question is this: what do i need to do to get my system to find this symbol, or is there something else I need to install? Any debugging suggestions welcomed.

like image 774
Schneems Avatar asked Oct 09 '22 15:10

Schneems


2 Answers

This is what I did to get it to work on Snow Leopard:

cd ..../gems/memprof-0.3.10/ext/

Edit Makefile, search for LD_SHARED=

Change from

LDSHARED = cc -arch x86_64 -dynamiclib -undefined suppress -flat_namespace

to

LDSHARED = cc -arch x86_64 -bundle -bundle_loader $(RUBY) -undefined suppress -flat_namespace

(replaced -dynamiclib with -bundle and -bundleloader options)

Then,

make install (which creates memprof.bundle and copies it to memprof*/lib)

Edit: Just to clarify, $(RUBY) must contain the full pathname to the ruby interpreter (the executable). Under RVM, the Makefile initializes it to the appropriate interpreter, so the above line works without a problem.

like image 109
Sriram Srinivasan Avatar answered Oct 18 '22 04:10

Sriram Srinivasan


Looks like it was not compiled correctly and was missing the linker flags for the bundle library. Try building it was LDFLAGS="-bundle"... I'm not sure how you do that with RVM, but I assume it will inherit the environment you give it.

EDIT | Sorry, looks like the correct ld flag may be: LDFLAGS="-bundler_loader" EDIT 2 | Actually, I'm not sure if it's bundle or bundle_loader... I'm seeing both in Google results.

like image 23
d11wtq Avatar answered Oct 18 '22 03:10

d11wtq