Blake Matheny

RSS

Building VIM 7.3 Against Ruby 1.9.3 on OS X

A quick search on google shows that building VIM against a modern ruby version on OS X isn’t trivial.

This is worth reading if you’re trying to build vim in this environment and have seen the following error:


dyld: Symbol not found: _environ
  Referenced from: /Users/bmatheny/.rvm/rubies/ruby-1.9.3-p194/lib/libruby.1.9.1.dylib
  Expected in: flat namespace
 in /Users/bmatheny/.rvm/rubies/ruby-1.9.3-p194/lib/libruby.1.9.1.dylib
[1]    54384 trace trap  ./src/vim.stripped --version

After you’ve grabbed the source for VIM and unpacked it, configure VIM as follows:

1. Configure VIM


./configure --with-features=huge --enable-cscope --enable-rubyinterp=yes --enable-multibyte --enable-clipboard=yes

Note that --enable-rubyinterp=yes is important.

2. Edit config.mk

Next, edit src/auto/config.mk and change the LDFLAGS line so it looks like:


LDFLAGS = -L. -arch x86_64 -L/Users/bmatheny/.rvm/rubies/ruby-1.9.3-p194/lib -L/usr/local/lib

This adds the rvm library path for the version of ruby you want to link against to the link path.

3. Fix the stripped version

When you run make install, the vim executable will get stripped (symbols will be removed). Just copy src/vim in place of /usr/local/bin/vim (or wherever you have it installed). The vim binary at src/vim still has a a fat symbol table.