title: Linker error with boost::program_options and C++11 on OSX
body: <p>I built boost thusly:</p>
  
  <pre><code>~/Downloads/boost_1_52_0
  $ sudo ./b2 --build-dir=build --layout=system -j4 toolset=clang variant=release link=shared runtime-link=shared threading=multi cxxflags="-std=c++11 -stdlib=libc++" linkflags="-stdlib=libc++" --without-mpi --without-python install
  </code></pre>
  
  <p>and then tried to compile the first example program</p>
  
  <pre><code>~/Downloads/boost_1_52_0
  $ cd libs/program_options/example                                                                                                                             [18:35:25]
  
  ~/Downloads/boost_1_52_0/libs/program_options/example
  $ c++ -v -std=c++11 -stdlib=libc++ -lboost_program_options -o first first.cpp                                                                                 [18:38:32]
  Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
  Target: x86_64-apple-darwin11.4.2
  Thread model: posix
   "/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.7.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name first.cpp -pic-level 1 -mdisable-fp-elim -relaxed-aliasing -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 134.9 -v -resource-dir /usr/bin/../lib/clang/4.1 -fmodule-cache-path /var/folders/sq/nfthwlb93k5bl9qyrjbvfylm0000gn/T/clang-module-cache -stdlib=libc++ -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /Users/lexi/Downloads/boost_1_52_0/libs/program_options/example -ferror-limit 19 -fmessage-length 169 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime-has-arc -fobjc-runtime-has-weak -fobjc-dispatch-method=mixed -fobjc-default-synthesize-properties -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/sq/nfthwlb93k5bl9qyrjbvfylm0000gn/T/first-oIjAae.o -x c++ first.cpp
  clang -cc1 version 4.1 based upon LLVM 3.1svn default target x86_64-apple-darwin11.4.2
  ignoring nonexistent directory "/usr/include/c++/v1"
  #include "..." search starts here:
  #include &lt;...&gt; search starts here:
   /usr/bin/../lib/c++/v1
   /usr/local/include
   /usr/bin/../lib/clang/4.1/include
   /usr/include
   /System/Library/Frameworks (framework directory)
   /Library/Frameworks (framework directory)
  End of search list.
   "/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.7.0 -o first -lcrt1.10.6.o -lboost_program_options /var/folders/sq/nfthwlb93k5bl9qyrjbvfylm0000gn/T/first-oIjAae.o -lc++ -lSystem /usr/bin/../lib/clang/4.1/lib/darwin/libclang_rt.osx.a
  Undefined symbols for architecture x86_64:
    "boost::program_options::validation_error::validation_error(boost::program_options::validation_error::kind_t, std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; const&amp;, std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; const&amp;)", referenced from:
        std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; const&amp; boost::program_options::validators::get_single_string&lt;char&gt;(std::__1::vector&lt;std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;, std::__1::allocator&lt;std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; &gt; &gt; const&amp;, bool) in first-oIjAae.o
    "boost::program_options::validation_error::what() const", referenced from:
        vtable for boost::exception_detail::error_info_injector&lt;boost::program_options::invalid_option_value&gt; in first-oIjAae.o
        vtable for boost::program_options::invalid_option_value in first-oIjAae.o
        vtable for boost::exception_detail::clone_impl&lt;boost::exception_detail::error_info_injector&lt;boost::program_options::invalid_option_value&gt; &gt; in first-oIjAae.o
        vtable for boost::exception_detail::error_info_injector&lt;boost::program_options::validation_error&gt; in first-oIjAae.o
        vtable for boost::exception_detail::clone_impl&lt;boost::exception_detail::error_info_injector&lt;boost::program_options::validation_error&gt; &gt; in first-oIjAae.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>What am I doing wrong? The only similar error I could find was <a href="https://stackoverflow.com/q/11979123/823542">Linker error with Boost &amp; C++ on OSX</a> but he is using CMake, gcc and c++03 and his solution of "I recompiled Boost and it worked" isn't particularly helpful.</p>
  
  <p>It's also definitely not the code's fault, since bjam can build the example, but I don't understand enough compiler-fu to be able to look at the output and go "oh so that's how you do it!"</p>
  
  <pre><code>~/Downloads/boost_1_52_0/libs/program_options/example
  $ ../../../b2 -ad+2 toolset=clang cxxflags="-std=c++11 -stdlib=libc++" linkflags="-stdlib=libc++" first
  clang-darwin.compile.c++ ../../../bin.v2/libs/program_options/example/clang-darwin-4.2.1/debug/link-static/first.o
  
      "clang++" -x c++ -O0 -g -std=c++11 -stdlib=libc++ -O0 -fno-inline -Wall -g -DBOOST_ALL_NO_LIB=1 -I"../../.." -c -o "../../../bin.v2/libs/program_options/example/clang-darwin-4.2.1/debug/link-static/first.o" "first.cpp"
  
  clang-darwin.compile.c++ ../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/cmdline.o
  
      "clang++" -x c++ -O0 -g -std=c++11 -stdlib=libc++ -O0 -fno-inline -Wall -g -DBOOST_ALL_NO_LIB=1 -I"../../.." -c -o "../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/cmdline.o" "../../../libs/program_options/src/cmdline.cpp"
  
  clang-darwin.compile.c++ ../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/config_file.o
  
      "clang++" -x c++ -O0 -g -std=c++11 -stdlib=libc++ -O0 -fno-inline -Wall -g -DBOOST_ALL_NO_LIB=1 -I"../../.." -c -o "../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/config_file.o" "../../../libs/program_options/src/config_file.cpp"
  
  clang-darwin.compile.c++ ../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/options_description.o
  
      "clang++" -x c++ -O0 -g -std=c++11 -stdlib=libc++ -O0 -fno-inline -Wall -g -DBOOST_ALL_NO_LIB=1 -I"../../.." -c -o "../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/options_description.o" "../../../libs/program_options/src/options_description.cpp"
  
  clang-darwin.compile.c++ ../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/parsers.o
  
      "clang++" -x c++ -O0 -g -std=c++11 -stdlib=libc++ -O0 -fno-inline -Wall -g -DBOOST_ALL_NO_LIB=1 -I"../../.." -c -o "../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/parsers.o" "../../../libs/program_options/src/parsers.cpp"
  
  clang-darwin.compile.c++ ../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/variables_map.o
  
      "clang++" -x c++ -O0 -g -std=c++11 -stdlib=libc++ -O0 -fno-inline -Wall -g -DBOOST_ALL_NO_LIB=1 -I"../../.." -c -o "../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/variables_map.o" "../../../libs/program_options/src/variables_map.cpp"
  
  clang-darwin.compile.c++ ../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/value_semantic.o
  
      "clang++" -x c++ -O0 -g -std=c++11 -stdlib=libc++ -O0 -fno-inline -Wall -g -DBOOST_ALL_NO_LIB=1 -I"../../.." -c -o "../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/value_semantic.o" "../../../libs/program_options/src/value_semantic.cpp"
  
  clang-darwin.compile.c++ ../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/positional_options.o
  
      "clang++" -x c++ -O0 -g -std=c++11 -stdlib=libc++ -O0 -fno-inline -Wall -g -DBOOST_ALL_NO_LIB=1 -I"../../.." -c -o "../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/positional_options.o" "../../../libs/program_options/src/positional_options.cpp"
  
  clang-darwin.compile.c++ ../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/utf8_codecvt_facet.o
  
      "clang++" -x c++ -O0 -g -std=c++11 -stdlib=libc++ -O0 -fno-inline -Wall -g -DBOOST_ALL_NO_LIB=1 -I"../../.." -c -o "../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/utf8_codecvt_facet.o" "../../../libs/program_options/src/utf8_codecvt_facet.cpp"
  
  In file included from ../../../libs/program_options/src/utf8_codecvt_facet.cpp:15:
  In file included from ../../../boost/detail/utf8_codecvt_facet.ipp:13:
  ../../../boost/detail/utf8_codecvt_facet.hpp:171:17: warning: 'boost::program_options::detail::utf8_codecvt_facet::do_length' hides overloaded virtual function [-Woverloaded-virtual]
      virtual int do_length(
                  ^
  /usr/bin/../lib/c++/v1/__locale:920:17: note: hidden overloaded virtual function 'std::__1::codecvt&lt;wchar_t, char, __mbstate_t&gt;::do_length' declared here
      virtual int do_length(state_type&amp;, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
                  ^
  1 warning generated.
  clang-darwin.compile.c++ ../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/convert.o
  
      "clang++" -x c++ -O0 -g -std=c++11 -stdlib=libc++ -O0 -fno-inline -Wall -g -DBOOST_ALL_NO_LIB=1 -I"../../.." -c -o "../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/convert.o" "../../../libs/program_options/src/convert.cpp"
  
  In file included from ../../../libs/program_options/src/convert.cpp:19:
  In file included from ../../../boost/program_options/detail/utf8_codecvt_facet.hpp:19:
  ../../../boost/detail/utf8_codecvt_facet.hpp:171:17: warning: 'boost::program_options::detail::utf8_codecvt_facet::do_length' hides overloaded virtual function [-Woverloaded-virtual]
      virtual int do_length(
                  ^
  /usr/bin/../lib/c++/v1/__locale:920:17: note: hidden overloaded virtual function 'std::__1::codecvt&lt;wchar_t, char, __mbstate_t&gt;::do_length' declared here
      virtual int do_length(state_type&amp;, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
                  ^
  1 warning generated.
  clang-darwin.compile.c++ ../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/winmain.o
  
      "clang++" -x c++ -O0 -g -std=c++11 -stdlib=libc++ -O0 -fno-inline -Wall -g -DBOOST_ALL_NO_LIB=1 -I"../../.." -c -o "../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/winmain.o" "../../../libs/program_options/src/winmain.cpp"
  
  clang-darwin.compile.c++ ../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/split.o
  
      "clang++" -x c++ -O0 -g -std=c++11 -stdlib=libc++ -O0 -fno-inline -Wall -g -DBOOST_ALL_NO_LIB=1 -I"../../.." -c -o "../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/split.o" "../../../libs/program_options/src/split.cpp"
  
  RmTemps ../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/libboost_program_options.a(clean)
  
      rm -f "../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/libboost_program_options.a" 
  
  clang-darwin.archive ../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/libboost_program_options.a
  
    "ar"  rc "../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/libboost_program_options.a" "../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/cmdline.o" "../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/config_file.o" "../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/options_description.o" "../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/parsers.o" "../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/variables_map.o" "../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/value_semantic.o" "../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/positional_options.o" "../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/utf8_codecvt_facet.o" "../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/convert.o" "../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/winmain.o" "../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/split.o"
    "ranlib" -cs "../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/libboost_program_options.a"
  
  clang-darwin.link ../../../bin.v2/libs/program_options/example/clang-darwin-4.2.1/debug/link-static/first
  
      "clang++" -stdlib=libc++ -stdlib=libc++  -o "../../../bin.v2/libs/program_options/example/clang-darwin-4.2.1/debug/link-static/first" "../../../bin.v2/libs/program_options/example/clang-darwin-4.2.1/debug/link-static/first.o" "../../../bin.v2/libs/program_options/build/clang-darwin-4.2.1/debug/link-static/libboost_program_options.a"    -g
  
  
  ~/Downloads/boost_1_52_0/libs/program_options/example
  $ ../../../bin.v2/libs/program_options/example/clang-darwin-4.2.1/debug/link-static/first
  Compression level was not set.
  </code></pre>