mac: Install MacVim
Today, trying to compile MacVim I ran into a problem with some shared libraries:
... Undefined symbols: "_iconv_close", referenced from: _buf_write in fileio.o _readfile in fileio.o _readfile in fileio.o ...
The problem has to do with lib search path. I don’t know yet why isn’t used the system path (under /usr/lib) rather than the one used by macports.
Well, the thing is that the libiconv2.dylib under /opt/local/lib doesn’t have the _iconv_close function (among others):
[madtrick { lib } ]pwd /opt/local/lib [madtrick { lib } ]nm libiconv.2.dylib | grep "iconv_close" 000163f0 T _libiconv_close
While libiconv.2.dylib on /usr/lib does:
[madtrick { lib } ]pwd /usr/lib [madtrick { lib } ]nm libiconv.2.dylib | grep "iconv_close" 0000b905 T _iconv_close 0000fcce T _libiconv_close
So to fix this problem you have several choices:
- Deactivate libiconv on macports (and all its dependencies)
- Prepend a lib path
I went for the second one:
LDFLAGS="-L/usr/lib" ./configure _your_options_here_
There you go : )
Category: mac, tweaks 4 comments »
July 9th, 2011 at 10:21 pm
Dude, your fix is great! I know there are a lot of people having this problem and I am sure your fix has been of HUGE help. Thanks a lot
July 10th, 2011 at 11:16 am
You’re welcome : )
September 23rd, 2011 at 11:08 pm
could you explain what the LDFLAGS does? I’ve had to use a solution like this twice but no one has ever explained why
November 10th, 2011 at 5:21 pm
Thanks!
@w3rd: the DLFAGS is an evironment variable used my the linker (which builds the executable from the various compiled c-program files (object files). This command line sets an environment variable, then executes the command
VARIABLE=”value” command
LDFLAGS=”-L/usr/lib” ./configure _your_options_here_
The “-L” flag tells the linker to look in that path to find the references system libraries to include, much like the “PATH” variable contains the list of directories to search to find a command file to load and execute.
In this case, we tell the linker to first look in the OSX system libraries (/usr/lib) before the macport libraries (/opt/local/lib). Sometimes macports builds versions with subtle differences that are not universally compatible.