title: Yet another "ld: symbol(s) not found for architecture x86_64" issue with boost, this time with mgiza
body: <p>I apologize for asking such a common question; I can't find any solution out there that works or is clear enough for me to implement. I am simply trying to install <a href="https://github.com/moses-smt/mgiza" rel="nofollow noreferrer">mgiza</a>. Here is the INSTALL file:</p>
  
  <pre><code>cmake .
  make
  make install
  
  If you want to install to a custom location, add the following flag when you run cmake:
  -DCMAKE_INSTALL_PREFIX=/path/to/custom/location
  
  NOTE: Boost Version 1.48 has problem with the code, you can use either 1.46 or 1.50+. Unfortunately 1.48 is shipped with Ubuntu 12.04 LTS, you can either download and compile libboost 1.50+ from their website, or just do this:
  sudo apt-get install libboost1.46-all-dev
  </code></pre>
  
  <p>Looks easy, right? Typing in <code>cmake .</code> works without any apparent problems. Unfortunately, <code>make</code> runs into this dreaded error ("undefined symbols ...") with boost.</p>
  
  <pre><code>1 warning generated.
  Linking CXX executable ../bin/d4norm
  Undefined symbols for architecture x86_64:
    "std::string::_Rep::_M_destroy(std::allocator&lt;char&gt; const&amp;)", referenced from:
        boost::system::(anonymous namespace)::generic_error_category::message(int) const in libboost_system-mt.a(error_code.o)
    "std::string::_Rep::_S_empty_rep_storage", referenced from:
        boost::system::(anonymous namespace)::generic_error_category::message(int) const in libboost_system-mt.a(error_code.o)
    "std::string::assign(char const*, unsigned long)", referenced from:
        boost::system::(anonymous namespace)::generic_error_category::message(int) const in libboost_system-mt.a(error_code.o)
    "std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;::basic_string(char const*, std::allocator&lt;char&gt; const&amp;)", referenced from:
        boost::system::(anonymous namespace)::generic_error_category::message(int) const in libboost_system-mt.a(error_code.o)
    "std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;::basic_string(std::string const&amp;)", referenced from:
        boost::system::(anonymous namespace)::generic_error_category::message(int) const in libboost_system-mt.a(error_code.o)
    "std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;::~basic_string()", referenced from:
        boost::system::(anonymous namespace)::generic_error_category::message(int) const in libboost_system-mt.a(error_code.o)
  ld: symbol(s) not found for architecture x86_64
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  </code></pre>
  
  <p>Based on other questions, it's a problem with Mavericks because it uses clang to compile c++ code, implying that the library is libc++, not libstdc++. For completeness, and so that others can reproduce my errors, I am using OS X 10.9.5, Xcode 6.1, and my boost version is 1.56 (boost was installed via homebrew).</p>
  
  <p>Now, there has to be <em>some</em> fix out there, right? Let's go through some of them:</p>
  
  <ol>
  <li><a href="https://stackoverflow.com/questions/9272566/gcc-ld-symbols-not-found-for-architecture-x86-64">Applying the -m32 flag</a>: not applicable because the Makefile
  doesn't have any "g++" in it, and it also explicitly tells me NOT to
  edit it, because it's a "Cmake" generated file.</li>
  <li><a href="https://stackoverflow.com/questions/21966887/undefined-symbols-for-architecture-x86-64-xcode-5-issues">Not defining something in a header file</a>: not applicable because the code should be ready to compile.</li>
  <li><a href="https://stackoverflow.com/questions/19637164/c-linking-error-after-upgrading-to-mac-os-x-10-9-xcode-5-0-1">Adding -stdlib=libstdc++ to linker</a>: I am not sure how to add this to a <code>make</code> command? I tried just doing <code>make -stdlib=libstdc++</code> and while that seemed to avoid the errors above, it introduced some additional errors: <code>make: *** [all] Error 2</code> (not sure what that means).</li>
  <li><a href="https://stackoverflow.com/questions/21590507/boost-xcode-c-command-line-undefined-symbols-for-architecture-x86-64">Linking to proper boost libraries</a>: There's a comment there that says "You just need to link to the proper boost libraries ... plenty of Q/As on how to do that". Unfortunately, I don't think any of the questions that commenter linked to address my problem.</li>
  <li><a href="https://stackoverflow.com/questions/25343335/boost-in-qt-installation-and-symbols-not-found-for-architectures-x86-64">Linking Qt with boost</a>: I don't think this is applicable because I'm not using Qt, and I don't know where I'd put in a <code>LIBS += [...] boost</code> line.</li>
  <li><a href="https://stackoverflow.com/questions/21297447/ld-symbols-not-found-for-architecture-x86-64">Linking a missing file</a>: That issue seems to be more about linking when running <code>g++</code> but I'm using a Makefile that doesn't have <code>g++</code> anywhere in it.</li>
  <li><a href="https://stackoverflow.com/questions/23496692/how-can-i-fix-g-undefined-symbols-for-architecture-x86-64-error">Using g++ vs gcc</a>: I don't know how I can change which of these I use, because I'm using <code>cmake</code> and <code>make</code>...</li>
  <li><a href="https://stackoverflow.com/questions/20202715/ld-symbols-not-found-for-architecture-x86-64-libusb">Changing a link command</a>: Again, I don't know how I can change the compilation from <code>cmake</code>/<code>make</code> to <code>gcc</code>. (Note: from this point on, I will ignore most questions that are answered by adding something to gcc or g++.)</li>
  <li><a href="https://stackoverflow.com/questions/19821041/g-ld-symbols-not-found-for-architecture-x86-64">Changing the standard c++ library</a>: the solution involves going into Xcode and changing the libraries there. I don't think this is the correct approach and in any case I'd probably screw up something if I changed a setting in Xcode (I also have no experience with Xcode's GUI).</li>
  <li><a href="https://stackoverflow.com/questions/13332807/cundefined-symbols-for-architecture-x86-64-mac-and-boost-library">Linking libraries in Xcode</a>: I think this is a similar case as #9 on this list. The answer here also recommends using homebrew instead of macports for installing boost, but I already said earlier that I used homebrew for installing boost.</li>
  <li><a href="https://trac.macports.org/ticket/41588" rel="nofollow noreferrer">Compile with clang</a>: A similar issue, but how do I get cmake or make to compile with clang?</li>
  <li><a href="https://github.com/bitcoin/bitcoin/issues/3228" rel="nofollow noreferrer">From a (popular) bitcoin issue</a>: Now <em>this</em> looks interesting! A ton of people ran into my error. Unfortunately, there seems to be no consensus or easy solution. There are also a few solutions that I don't know to implement. For instance, one solution by "imbolo" there is to compile boost using a cxxflag flag, but what does that mean?</li>
  </ol>
  
  <p>So I'm at a little bit of a loss on how to correctly install mgiza ... I mean, the whole point of mgiza giving me <code>cmake</code> and <code>make</code> is so that I <em>don't</em> have to worry about the messy details of compiling things, right? This isn't just an mgiza issue, though, since I've run into this problem when trying to do <code>make</code> elsewhere. I understand the high-level ideas of (C)Makefiles, but not the low-level details.</p>