2

I'm trying to compile SDL 2.0 on OS X 10.6, but I've been getting this message:

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

I've read the issues over at https://github.com/mxcl/homebrew/issues/894 and How to replace MacPort's libiconv with Mac's default 64-bit version? to see if either of them help. I uninstalled everything that MacPorts had since those two seemed to suggest that the issue was related to multiple versions of the same library (libiconv it had installed had way too many dependencies to manually uninstall them all, and I didn't need them anymore), but am still getting the same error. Any ideas?

Community
  • 1
  • 1
Ryan
  • 712
  • 7
  • 21
  • 1
    How are you compiling? With Xcode? A makefile? Invoking the linker on the command line? In any case, you need to add `-liconv` to link in the iconv library, as well as possibly `-L/path/to/libiconv/folder` to add it to the linker search path. – Adam Rosenfield Nov 01 '12 at 04:18
  • I'm compiling with a makefile. It looks like it already is using -liconv for linking. I'll try adding the path to the folder containing libiconv and see if that changes anything. – Ryan Nov 01 '12 at 07:33

2 Answers2

4

So it turns out after uninstalling the MacPorts copy, I still had 2 copies of libiconv on my computer that were different. One was in /usr/lib, and the other was in /usr/local/lib. Compiling with the one in /usr/lib produced the error above, however adding -L/usr/local/lib to the EXTRA_LDFLAGS variable in the Makefile worked.

Ryan
  • 712
  • 7
  • 21
2

I found a simple solution. Just add 2 more parameters when configure SDL source:

./configure CPPFLAGS='-I/opt/local/include' LDFLAGS='-L/opt/local/lib'
h00w
  • 675
  • 6
  • 4