title: OS X compile error: ld: symbol(s) not found for architecture x86_64
body: <p>New to compiling here, so bear with me.  I'm trying to compile some c++ code on OS X 10.10.3 using <code>make</code>. I have XCode 6.3.1 installed. My Makefile was generated using qmake.  The compiler runs well until it tries to run the final build command and throws an error:</p>
  
  <pre><code>Undefined symbols for architecture x86_64:
    "_iconv", referenced from:
        puntoexe::charsetConversionIconv::myIconv(void*, char*, unsigned long) const in charsetConversionIconv.o
    "_iconv_close", referenced from:
        puntoexe::charsetConversionIconv::close() in charsetConversionIconv.o
    "_iconv_open", referenced from:
        puntoexe::charsetConversionIconv::initialize(int) in charsetConversionIconv.o
  ld: symbol(s) not found for architecture x86_64
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  make: *** [dicom2jpeg.app/Contents/MacOS/dicom2jpeg] Error 1
  </code></pre>
  
  <p>I have found multiple threads here describing a similar problem, and apparently it comes down to the compiler linking to a 32 bit library.  The main suggestion that works for others is to add the following code to the Makefile:</p>
  
  <pre><code>-stdlib=libstdc++
  </code></pre>
  
  <p>The qmake-generated Makefile looks like this:</p>
  
  <pre><code>CC            = clang
  CXX           = clang++
  DEFINES       = -DQT_NO_DEBUG
  CFLAGS        = -pipe -mmacosx-version-min=10.7 -O2 -arch x86_64 -Wall -W $(DEFINES)
  CXXFLAGS      = -pipe -stdlib=libc++ -mmacosx-version-min=10.7 -O2 -arch x86_64 -Wall -W $(DEFINES)
  INCPATH       = -I/usr/local/Cellar/qt/4.8.6/mkspecs/unsupported/macx-clang-libc++ -I. -I/usr/local/Cellar/qt/4.8.6/include -I.
  LINK          = clang++
  LFLAGS        = -headerpad_max_install_names -stdlib=libc++ -mmacosx-version-min=10.7 -arch x86_64
  LIBS          = $(SUBLIBS)  -L/usr/local/Cellar/qt/4.8.6/lib -lpthread
  </code></pre>
  
  <p>So, I've changed my Makefile to link to the appropriate library:</p>
  
  <pre><code>CC            = clang
  CXX           = clang++
  DEFINES       = -DQT_NO_DEBUG
  CFLAGS        = -pipe -mmacosx-version-min=10.7 -O2 -arch x86_64 -Wall -W $(DEFINES)
  CXXFLAGS      = -pipe -stdlib=libstdc++ -mmacosx-version-min=10.7 -O2 -arch x86_64 -Wall -W $(DEFINES)
  INCPATH       = -I/usr/local/Cellar/qt/4.8.6/mkspecs/unsupported/macx-clang-libc++ -I. -I/usr/local/Cellar/qt/4.8.6/include -I.
  LINK          = clang++
  LFLAGS        = -headerpad_max_install_names -stdlib=libstdc++ -mmacosx-version-min=10.7 -arch x86_64
  LIBS          = $(SUBLIBS)  -L/usr/local/Cellar/qt/4.8.6/lib -lpthread
  </code></pre>
  
  <p>But, no dice.  Still throwing the same error on final build.  Am I missing something?  </p>