zoukankan      html  css  js  c++  java
  • mac gcc std Undefined symbols for architecture x86_64

    Error:

    Undefined symbols for architecture x86_64:
    "std::__1::locale::use_facet(std::__1::locale::id&) const", referenced from:
    std::__1::ctype<char> const& std::__1::use_facet<std::__1::ctype<char> >(std::__1::locale const&) in test-80e721.o
    "std::__1::ios_base::getloc() const", referenced from:
    std::__1::basic_ios<char, std::__1::char_traits<char> >::widen(char) const in test-80e721.o
    "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__init(unsigned long, char)", referenced from:
    std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string(unsigned long, char) in test-80e721.o
    "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_string()", referenced from:
    std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > std::__1::__pad_and_output<char, std::__1::char_traits<char> >(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char const*, char const*, char const*, std::__1::ios_base&, char) in test-80e721.o
    "std::__1::basic_istream<char, std::__1::char_traits<char> >::operator>>(int&)", referenced from:
    _main in test-80e721.o
    "std::__1::basic_ostream<char, std::__1::char_traits<char> >::put(char)", referenced from:
    std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::endl<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) in test-80e721.o
    "std::__1::basic_ostream<char, std::__1::char_traits<char> >::flush()", referenced from:
    std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::endl<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) in test-80e721.o
    "std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::sentry(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)", referenced from:
    std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in test-80e721.o
    "std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::~sentry()", referenced from:
    std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in test-80e721.o
    "std::__1::basic_ostream<char, std::__1::char_traits<char> >::operator<<(int)", referenced from:
    _main in test-80e721.o
    "std::__1::cin", referenced from:
    _main in test-80e721.o
    "std::__1::cout", referenced from:
    _main in test-80e721.o
    "std::__1::ctype<char>::id", referenced from:
    std::__1::ctype<char> const& std::__1::use_facet<std::__1::ctype<char> >(std::__1::locale const&) in test-80e721.o
    "std::__1::locale::~locale()", referenced from:
    std::__1::basic_ios<char, std::__1::char_traits<char> >::widen(char) const in test-80e721.o
    "std::__1::ios_base::__set_badbit_and_consider_rethrow()", referenced from:
    std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in test-80e721.o
    "std::__1::ios_base::clear(unsigned int)", referenced from:
    std::__1::ios_base::setstate(unsigned int) in test-80e721.o
    "std::terminate()", referenced from:
    ___clang_call_terminate in test-80e721.o
    "___cxa_begin_catch", referenced from:
    std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in test-80e721.o
    ___clang_call_terminate in test-80e721.o
    "___cxa_call_unexpected", referenced from:
    std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >::ostreambuf_iterator(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) in test-80e721.o
    "___cxa_end_catch", referenced from:
    std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in test-80e721.o
    "___gxx_personality_v0", referenced from:
    std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in test-80e721.o
    std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > std::__1::__pad_and_output<char, std::__1::char_traits<char> >(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char const*, char const*, char const*, std::__1::ios_base&, char) in test-80e721.o
    std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >::ostreambuf_iterator(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) in test-80e721.o
    std::__1::basic_ios<char, std::__1::char_traits<char> >::widen(char) const in test-80e721.o
    Dwarf Exception Unwind Info (__eh_frame) in test-80e721.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    DHMBP:cpp $ cc test.cc 
    Undefined symbols for architecture x86_64:
    "std::__1::locale::use_facet(std::__1::locale::id&) const", referenced from:
    std::__1::ctype<char> const& std::__1::use_facet<std::__1::ctype<char> >(std::__1::locale const&) in test-325e11.o
    "std::__1::ios_base::getloc() const", referenced from:
    std::__1::basic_ios<char, std::__1::char_traits<char> >::widen(char) const in test-325e11.o
    "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__init(unsigned long, char)", referenced from:
    std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string(unsigned long, char) in test-325e11.o
    "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_string()", referenced from:
    std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > std::__1::__pad_and_output<char, std::__1::char_traits<char> >(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char const*, char const*, char const*, std::__1::ios_base&, char) in test-325e11.o
    "std::__1::basic_istream<char, std::__1::char_traits<char> >::operator>>(int&)", referenced from:
    _main in test-325e11.o
    "std::__1::basic_ostream<char, std::__1::char_traits<char> >::put(char)", referenced from:
    std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::endl<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) in test-325e11.o
    "std::__1::basic_ostream<char, std::__1::char_traits<char> >::flush()", referenced from:
    std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::endl<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) in test-325e11.o
    "std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::sentry(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)", referenced from:
    std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in test-325e11.o
    "std::__1::basic_ostream<char, std::__1::char_traits<char> >::sentry::~sentry()", referenced from:
    std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in test-325e11.o
    "std::__1::basic_ostream<char, std::__1::char_traits<char> >::operator<<(int)", referenced from:
    _main in test-325e11.o
    "std::__1::cin", referenced from:
    _main in test-325e11.o
    "std::__1::cout", referenced from:
    _main in test-325e11.o
    "std::__1::ctype<char>::id", referenced from:
    std::__1::ctype<char> const& std::__1::use_facet<std::__1::ctype<char> >(std::__1::locale const&) in test-325e11.o
    "std::__1::locale::~locale()", referenced from:
    std::__1::basic_ios<char, std::__1::char_traits<char> >::widen(char) const in test-325e11.o
    "std::__1::ios_base::__set_badbit_and_consider_rethrow()", referenced from:
    std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in test-325e11.o
    "std::__1::ios_base::clear(unsigned int)", referenced from:
    std::__1::ios_base::setstate(unsigned int) in test-325e11.o
    "std::terminate()", referenced from:
    ___clang_call_terminate in test-325e11.o
    "___cxa_begin_catch", referenced from:
    std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in test-325e11.o
    ___clang_call_terminate in test-325e11.o
    "___cxa_call_unexpected", referenced from:
    std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >::ostreambuf_iterator(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) in test-325e11.o
    "___cxa_end_catch", referenced from:
    std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in test-325e11.o
    "___gxx_personality_v0", referenced from:
    std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in test-325e11.o
    std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > std::__1::__pad_and_output<char, std::__1::char_traits<char> >(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char const*, char const*, char const*, std::__1::ios_base&, char) in test-325e11.o
    std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >::ostreambuf_iterator(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) in test-325e11.o
    std::__1::basic_ios<char, std::__1::char_traits<char> >::widen(char) const in test-325e11.o
    Dwarf Exception Unwind Info (__eh_frame) in test-325e11.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

    解决方案:

    gcc 开启使用标准c++库即可

    比如:

    gcc -lstdc++ Person.cpp -o Person

  • 相关阅读:
    Develop an Android Application
    有效提高编程技能
    如何提高团队编程水平
    ruby测试框架
    grep:Binary file (standard input) matches
    python datetime相减
    软件开发的“三重门
    Linux高手之路SVN使用笔记
    机器io高原因排查全命令指南
    代码如写作
  • 原文地址:https://www.cnblogs.com/dhcn/p/12485420.html
Copyright © 2011-2022 走看看