问题
I'm trying to build Hercules from the latest Subversion on Mac OS X 10.6. It uses the iconv library for character translations. The Hercules code uses iconv_open(), iconv(), and iconv_close(). Those routines are also present in the system library on 10.6, under those names. There's only one problem: I'm getting link failures for libiconv_open(), libiconv(), and libiconv_close().
I've hunted all over my system for where the names are being changed from iconv* to libiconv*, and not found a thing. Nothing in the Hercules code is doing this. Other folks are able to build fine on current OS X.
I'm missing something simple, but just can't find it. Help?
回答1:
I got this:
checking for iconv_open in -liconv... yes
checking for iconv... yes
....
Undefined symbols:
"_libiconv_open", referenced from:
_SDL_iconv_string in SDL_iconv.o
_SDL_iconv_string in SDL_iconv.o
"_libiconv", referenced from:
_SDL_iconv in SDL_iconv.o
_SDL_iconv_string in SDL_iconv.o
"_libiconv_close", referenced from:
_SDL_iconv_string in SDL_iconv.o
_SDL_iconv_string in SDL_iconv.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [build/libSDL.la] Error 1
until I removed my two other copies in /opt/local and /usr/local (from Macports and a raw build of the GNU package). Then it worked.
回答2:
Beeing a bit late, in my case the following line did it (MacOS X 10.8.4):
CFLAGS='-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/' LDFLAGS='-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/ -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/' ./configure
I had to override the autotools LDFLAGS to tell the configure script to use the libraries shipped with the XCode SDK.
来源:https://stackoverflow.com/questions/4546484/iconv-routines-get-translated-to-libiconv-names-and-fail-to-link-on-os-x