How to compile VIM under OS X

Configure and compiling VIM under OS X did not work out-of-the box for me. I did not want to use MacPorts VIM as it’s dependent on ruby (if you like me want that) and I did not find a way of compiling MacPorts VIM against my local ruby.

This post is about how to get VIM compiling on OS X/intel without the use of MacPorts.

1. Configure without specifying architecture

When running configure without specifying architecture everything looks fine but when you run make you get this nice little error.

1
2
3
4
5
6
7
8
9
10
11
12
./configure --enable-rubyinterp --enable-multibyte --with-features=huge
... stripped output ...
make

Undefined symbols for architecture ppc:
  "_main", referenced from:
      start in crt1.10.5.o
ld: symbol(s) not found for architecture ppc
collect2: ld returned 1 exit status
lipo: can't open input file: /var/folders/os/osNwawQ0Hreve7NDQEugQ++++TI/-Tmp-//ccD17Dx3.out (No such file or directory)
make[1]: *** [Vim] Error 1
make: *** [first] Error 2

I did not do any Sherlock holmes work to understand this message as I do not need PPC support. I learned that there is a flag called ‘–with-mac-arch‘.

2. configure with specifying architecture

1
2
3
4
5
6
7
8
9
10
11
12
> ./configure --with-mac-arch=intel --enable-rubyinterp --enable-multibyte --with-features=huge

checking --with-tlib argument... empty: automatic terminal library selection
checking for tgetent in -lncurses... (cached) yes
ncurses library is not usable
checking for tgetent in -ltermlib... no
checking for tgetent in -ltermcap... no
checking for tgetent in -lcurses... no
no terminal library found
checking for tgetent()... configure: error: NOT FOUND!
      You need to install a terminal library; for example ncurses.
      Or specify the name of the library with --with-tlib.

But as you can see specifying architecture did not even make is trough configure. I tried to specifying –with-tlib and adding LIBS path did not help. I did spend quite some time on this step to solve this one, but no luck here.

3. The working solution.

This became the working solution for me. Not that pretty but it did work :)

Run ./configure without arch flags.

1
./configure --enable-rubyinterp --enable-multibyte --with-features=huge

When done, edit src/auto/config.mk and remove PPC arch.
And yes! I know editing src/auto/config.mk is not that good and that the file is getting overwritten every time you run configure

1
> vim src/auto/config.mk

on Line 26

1
  LDFLAGS   = -L. -arch ppc -arch i386  -L/usr/local/lib

Remove the PPC part “-arch ppc
After removing PPC you can run:

1
2
make
sudo make install

I hope this can save someone else some time and i hope this is one of many to come blog posts that involves VIM!

Cheers!

Posted in Programming at January 11th, 2009. Trackback URI: trackback Tags: , , , Written by: 
  • Nik Krimm

    Thanks, this was really helpful.

  • http://amaslov.wordpress.com Alexey Maslov

    Why not use MacVim?

  • Mathias Stjernstr√∂m

    I spend almost all my time in the console so having the editor there is pretty nice. One more benefit is that I can use vim the same way on a server (with the same config). Using MVIM let you use some specialities thats not available without GUI.

    I also found MVIM a bit laggy but this was some time ago so it may have been fixed by now.

    Cheers!

  • Pingback: Getting Vim up and running under Snow Leopard - pastbedti.me()

  • lahwran

    this saved me hours of trouble tracking down that second issue. I tried macvim and hated that I can’t really make left command into a second control like I did in iTerm.

  • http://www.tigraine.at Daniel H√∂lbling

    Because some people (like me) prefer to use Vim from the Shell using some kind of Terminal Multiplexer like screen or tmux.. MacVim only runs in it’s GUI that I find annoying.

It's past my bedtime is using WP-Gravatar