Update: I can now compile vim without any tweak on OS X 10.7.4 with Homebrew without Macports. Also check the comments from jay and jefk, which make the compilation as easy.
The default vim of Max OS X is 7.2 without +python. I need pyflakes plugins, so I have to compile it. I like using terminal, so I don’t use MacVim.
configure and make with simple options:
./configure --prefix=/usr --enable-perlinterp=yes --enable-pythoninterp=yes --with-features=huge make
I got such error:
Undefined symbols for architecture x86_64: "_iconv", referenced from: _buf_write_bytes in fileio.o _readfile in fileio.o _my_iconv_open in mbyte.o _string_convert_ext in mbyte.o (maybe you meant: _my_iconv_open) "_iconv_close", referenced from: _buf_write in fileio.o _readfile in fileio.o _my_iconv_open in mbyte.o _convert_setup_ext in mbyte.o "_iconv_open", referenced from: _my_iconv_open in mbyte.o (maybe you meant: _my_iconv_open) ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status make[1]: *** [vim] Error 1 make: *** [first] Error 2
From google, I know that libiconv from macports doesn’t support x86_64.
Update: Thanks to jay’s remind, the libiconv comes with system should be fine. So, to specify the library, use the following to configure
LDFLAGS=-L/usr/lib ./configure --enable-perlinterp=yes --enable-pythoninterp=yes --with-features=huge
The solution is to download and compile and install libiconv. Download from http://www.gnu.org/software/libiconv/, compile and make & make install
CFLAGS='-arch i386 -arch x86_64' CCFLAGS='-arch i386 -arch x86_64' CXXFLAGS='-arch i386 -arch x86_64' ./configure make sudo make install
After install, it should be OK to compile vim. But I failed, and spent a whole afternoon. Finally, I removed the src, and use “hg up -C” to recover to get a clean copy, and then succeed! Amazing, maybe there were some “cache” files to record the old libiconv library path. Anyway, I could use vim7.3 in Mac OS X with +python now.
Update: Just remove all files exclude configure in src/auto, and reconfigure without cache.
Update: It works on Lion, too.
中文
Just so everyone knows, if you use any of –enable-pythoninterp=yes –enable-python3interp=yes –enable-rubyinterp=yes you will get this same error.
To get around you need to explicitly set LDFLAGS. For ruby I installed the MacPorts version for this and used that for linking (/opt/local/lib). For python, the default install is in /Library/Frameworks/Python.framework/Versions//lib where version is your python version.
To install vim fully I used the following flags:
export CPPFLAGS=”-I/usr/local/include -I/Library/Frameworks/Python.framework/Versions/2.7/includ
e -I/Library/Frameworks/Python.framework/Versions/3.1/include -I/opt/local/include -arch x86_64″
export CXXFLAGS=”-I/usr/local/include -I/Library/Frameworks/Python.framework/Versions/2.7/includ e -I/Library/Frameworks/Python.framework/Versions/3.1/include -I/opt/local/include -arch x86_64″
export CFLAGS=”-I/usr/local/include -I/Library/Frameworks/Python.framework/Versions/2.7/include -I/Library/Frameworks/Python.framework/Versions/3.1/include -I/opt/local/include -arch x86_64″
export LDFLAGS=”-L/usr/local/lib -R/usr/local/lib -L/Library/Frameworks/Python.framework/Version s/2.7/lib -R/Library/Frameworks/Python.framework/Versions/2.7/lib -L/Library/Frameworks/Python.f ramework/Versions/3.1/lib -R/Library/Frameworks/Python.framework/Versions/3.1/lib -L/opt/local/l ib -R/opt/local/lib”
This worked great for me!
Sorry, I need to modify my previous comment.
I kept failing on ruby. In the end I gave up, what I tried is below. My guess is that by building your own 64bit ruby with the right flags – probably both shared and static libraries – you could get it to work, provide you give the linker the right path. I don’t use ruby though, so I gave up.
Good luck
————————————
To use –enable-rubyinterp=yes with MacPorts ruby you need to use /opt/local/lib/ruby/1.8 You can also use the default ruby with /usr/lib/ruby/1.8
So LDFLAGS:
export LDFLAGS=”-L/usr/local/lib -R/usr/local/lib -L/Library/Frameworks/Python.framework/Version s/2.7/lib -R/Library/Frameworks/Python.framework/Versions/2.7/lib -L/Library/Frameworks/Python.f ramework/Versions/3.1/lib -R/Library/Frameworks/Python.framework/Versions/3.1/lib -L/usr/lib/rub y/1.8 -R/usr/lib/ruby/1.8 -L/opt/local/lib -R/opt/local/lib”
Well, I compiled without python3 and ruby, and no extra errors.
However, thanks for sharing. It’ll be surely useful when I go for python3.
i had a similar problem with the ruby interp, it turns out the vim binary was fine, but when running `make install` a call to `strip` on the binary is run rendering it unusable.
I believe I’ve found a very simple solution to this problem.
ISSUE:
During the MacVim build process, the path /opt/local/lib/ is searched for libraries. If you have used macports to install libiconv, the linker will find it before the system version of libiconv ( found in /usr/lib/ ). The macports version is not x86_64 while the system version is.
SOLUTION:
mkdir ~/temp
sudo mv /opt/local/lib/libiconv* ~/temp/
Go about the MacVim build. (Don’t forget to run ‘make clean’)
sudo mv ~/temp/libiconv* /opt/local/lib/
FEEDBACK:
Let me know if there is a more elegant solution, or if my solution is broken and why.
It just works. However, I’m using some packages like zsh, so difficult to do the compilation without it. I should compile vim before I install macports.
It’s still good to have a newer libiconv than the system one.
I’m inspired, that I can specify library path for it. I’ll try it later.
Thank you very much !
great thanks! saved my time!
@Mike Thanks for those exports, did the trick for me on lion with vim 7.3 –with-features=huge
Mike Dacre’s comment worked for me to run
./configure –with-features=huge –enable-pythoninterp
Note that there’s an additional space that needs to be removed in the LDFLAGS command
-L/opt/local/l ib
s/be
-L/opt/local/lib
try to install libconv first
https://gist.github.com/1778685/c30f5c6d0e1ea5c271faca3807e9665d44bde132
It also works if you use
LIBS="/usr/lib/libiconv.2.dylib" ./configure ....althoughvimcompiled without that addition on my machine running Mac OS X 10.6.8 as well.So try again, but make sure you are building against system libs only!
cd vim73
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
sudo mv -i /opt/local /opt/local-off
#sudo mv -i /usr/local /usr/local-off
sudo mkdir -p /usr/local/lib
./configure --prefix=/usr/local --enable-perlinterp=yes --enable-pythoninterp=yes --with-features=huge
make
make test # Test results: ALL DONE
otool -L src/vim
# ...
# /usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
# ...
# /System/Library/Frameworks/Python.framework/Versions/2.6/Python (compatibility version 2.6.0, current version 2.6.1)
# ...
sudo make install
sudo mv -i /opt/local-off /opt/local
#sudo ditto -V /usr/local-off /usr/local
That’s right. I just tried on OS X 10.7.4, and it just works without any tweaks.
I’m guessing the problem is about macports (I’m using Homebrew now).