简体   繁体   English

Ruby 1.8.7:找不到符号错误

[英]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 刚刚在一台带有新宝石套装的机器上安装了新的红宝石1.8.7 REE和MRI(使用RVM)但是当我尝试使用memprof时我得到了这个错误

$ 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 . 错误是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. 欢迎任何调试建议。

This is what I did to get it to work on Snow Leopard: 这就是我在Snow Leopard上工作的方法:

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

Edit Makefile, search for LD_SHARED= 编辑Makefile,搜索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) (用-bundle和-bundleloader选项替换了-dynamiclib)

Then, 然后,

make install (which creates memprof.bundle and copies it to memprof*/lib) make install (创建memprof.bundle并将其复制到memprof * / lib)

Edit: Just to clarify, $(RUBY) must contain the full pathname to the ruby interpreter (the executable). 编辑:只是为了澄清, $(RUBY)必须包含ruby解释器(可执行文件)的完整路径名。 Under RVM, the Makefile initializes it to the appropriate interpreter, so the above line works without a problem. 在RVM下,Makefile将它初始化为适当的解释器,因此上面的行工作没有问题。

Looks like it was not compiled correctly and was missing the linker flags for the bundle library. 看起来它没有正确编译,并且缺少bundle库的链接器标志。 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. 尝试构建它是LDFLAGS="-bundle" ...我不确定你是如何使用RVM的,但我认为它会继承你给它的环境。

EDIT | 编辑| Sorry, looks like the correct ld flag may be: LDFLAGS="-bundler_loader" EDIT 2 | 对不起,看起来正确的ld标志可能是: LDFLAGS="-bundler_loader" EDIT 2 | Actually, I'm not sure if it's bundle or bundle_loader ... I'm seeing both in Google results. 实际上,我不确定它是bundle还是bundle_loader ......我在Google搜索结果中都看到了这两个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM