title: GCC error: Undefined symbols for architecture x86_64
body: <p>Today I experimented with GCC/G++ :(</p>
  <p>I was not sure which c++ standards were installed (completely new to c++), so I updated gcc to the latest version with brew (<code>brew install gcc --HEAD</code>) but now it seems that the latest version is unfortunately unstable for my setup.</p>
  <p>clang version before: Apple clang version 12.0.0 (clang-1200.0.32.27)</p>
  <p>clang version after: Apple clang version 12.0.0 (clang-1200.0.32.27) but with following error:</p>
  <pre><code>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>OS: macOS@11.0.1</p>
  <p>Does anyone knows how to solve this? I am still able to use g++, only gcc is not working at all, no matter of <code>-std=</code> flag or not. Is installing the latest stable version a proper solution or will this make it worse ;-) ?</p>
  <pre><code>gcc helloworld.cc -v -o out
  Apple clang version 12.0.0 (clang-1200.0.32.27)
  Target: x86_64-apple-darwin20.1.0
  Thread model: posix
  InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
  ignoring nonexistent directory &quot;/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1&quot;
   &quot;/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang&quot; -cc1 -triple x86_64-apple-macosx11.0.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name helloworld.cc -mrelocation-model pic -pic-level 2 -mthread-model posix -mframe-pointer=all -fno-strict-return -masm-verbose -munwind-tables -target-sdk-version=11.0 -target-cpu penryn -dwarf-column-info -debugger-tuning=lldb -target-linker-version 609.6 -v -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -I/usr/local/include -stdlib=libc++ -internal-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1 -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include -internal-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion -fdeprecated-macro -fdebug-compilation-dir &quot;/Users/user/x/y/z/zz/zzz&quot; -ferror-limit 19 -fmessage-length 167 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fobjc-runtime=macosx-11.0.0 -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/rq/6cbshbgd2bdbpl3tqf7cg27c0000gn/T/helloworld-3e60f0.o -x c++ helloworld.cc
  clang -cc1 version 12.0.0 (clang-1200.0.32.27) default target x86_64-apple-darwin20.1.0
  ignoring nonexistent directory &quot;/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include&quot;
  ignoring nonexistent directory &quot;/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Library/Frameworks&quot;
  #include &quot;...&quot; search starts here:
  #include &lt;...&gt; search starts here:
   /usr/local/include
   /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1
   /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include
   /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
   /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
   /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
  End of search list.
   &quot;/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld&quot; -demangle -lto_library /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib -no_deduplicate -dynamic -arch x86_64 -platform_version macos 11.0.0 11.0 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -o out -L/usr/local/lib /var/folders/rq/6cbshbgd2bdbpl3tqf7cg27c0000gn/T/helloworld-3e60f0.o -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/lib/darwin/libclang_rt.osx.a
  Undefined symbols for architecture x86_64:
    &quot;std::__1::locale::use_facet(std::__1::locale::id&amp;) const&quot;, referenced from:
        std::__1::ctype&lt;char&gt; const&amp; std::__1::use_facet&lt;std::__1::ctype&lt;char&gt; &gt;(std::__1::locale const&amp;) in helloworld-3e60f0.o
    &quot;std::__1::ios_base::getloc() const&quot;, referenced from:
        std::__1::basic_ios&lt;char, std::__1::char_traits&lt;char&gt; &gt;::widen(char) const in helloworld-3e60f0.o
    &quot;std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;::__init(unsigned long, char)&quot;, referenced from:
        std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;::basic_string(unsigned long, char) in helloworld-3e60f0.o
    &quot;std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt;::~basic_string()&quot;, referenced from:
        std::__1::ostreambuf_iterator&lt;char, std::__1::char_traits&lt;char&gt; &gt; std::__1::__pad_and_output&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::ostreambuf_iterator&lt;char, std::__1::char_traits&lt;char&gt; &gt;, char const*, char const*, char const*, std::__1::ios_base&amp;, char) in helloworld-3e60f0.o
    &quot;std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;::put(char)&quot;, referenced from:
        std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; std::__1::endl&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;) in helloworld-3e60f0.o
    &quot;std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;::flush()&quot;, referenced from:
        std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; std::__1::endl&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;) in helloworld-3e60f0.o
    &quot;std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;::sentry::sentry(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;)&quot;, referenced from:
        std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; std::__1::__put_character_sequence&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;, char const*, unsigned long) in helloworld-3e60f0.o
    &quot;std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;::sentry::~sentry()&quot;, referenced from:
        std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; std::__1::__put_character_sequence&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;, char const*, unsigned long) in helloworld-3e60f0.o
    &quot;std::__1::cout&quot;, referenced from:
        _main in helloworld-3e60f0.o
    &quot;std::__1::ctype&lt;char&gt;::id&quot;, referenced from:
        std::__1::ctype&lt;char&gt; const&amp; std::__1::use_facet&lt;std::__1::ctype&lt;char&gt; &gt;(std::__1::locale const&amp;) in helloworld-3e60f0.o
    &quot;std::__1::locale::~locale()&quot;, referenced from:
        std::__1::basic_ios&lt;char, std::__1::char_traits&lt;char&gt; &gt;::widen(char) const in helloworld-3e60f0.o
    &quot;std::__1::ios_base::__set_badbit_and_consider_rethrow()&quot;, referenced from:
        std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; std::__1::__put_character_sequence&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;, char const*, unsigned long) in helloworld-3e60f0.o
    &quot;std::__1::ios_base::clear(unsigned int)&quot;, referenced from:
        std::__1::ios_base::setstate(unsigned int) in helloworld-3e60f0.o
    &quot;std::terminate()&quot;, referenced from:
        ___clang_call_terminate in helloworld-3e60f0.o
    &quot;___cxa_begin_catch&quot;, referenced from:
        std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; std::__1::__put_character_sequence&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;, char const*, unsigned long) in helloworld-3e60f0.o
        ___clang_call_terminate in helloworld-3e60f0.o
    &quot;___cxa_call_unexpected&quot;, referenced from:
        std::__1::ostreambuf_iterator&lt;char, std::__1::char_traits&lt;char&gt; &gt;::ostreambuf_iterator(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;) in helloworld-3e60f0.o
    &quot;___cxa_end_catch&quot;, referenced from:
        std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; std::__1::__put_character_sequence&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;, char const*, unsigned long) in helloworld-3e60f0.o
    &quot;___gxx_personality_v0&quot;, referenced from:
        std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; std::__1::__put_character_sequence&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;, char const*, unsigned long) in helloworld-3e60f0.o
        std::__1::ostreambuf_iterator&lt;char, std::__1::char_traits&lt;char&gt; &gt; std::__1::__pad_and_output&lt;char, std::__1::char_traits&lt;char&gt; &gt;(std::__1::ostreambuf_iterator&lt;char, std::__1::char_traits&lt;char&gt; &gt;, char const*, char const*, char const*, std::__1::ios_base&amp;, char) in helloworld-3e60f0.o
        std::__1::ostreambuf_iterator&lt;char, std::__1::char_traits&lt;char&gt; &gt;::ostreambuf_iterator(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;) in helloworld-3e60f0.o
        std::__1::basic_ios&lt;char, std::__1::char_traits&lt;char&gt; &gt;::widen(char) const in helloworld-3e60f0.o
        Dwarf Exception Unwind Info (__eh_frame) in helloworld-3e60f0.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>