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

  • 相关阅读:
    【bzoj3566】[SHOI2014]概率充电器 树形概率dp
    【bzoj1419】Red is good 期望dp
    【bzoj2698】染色 期望
    【bzoj2134】单选错位 期望
    【bzoj1022】[SHOI2008]小约翰的游戏John 博弈论
    【bzoj3170】[Tjoi 2013]松鼠聚会 旋转坐标系
    【bzoj2338】[HNOI2011]数矩形 计算几何
    【bzoj2085】[Poi2010]Hamsters Hash+倍增Floyd
    【bzoj1014】[JSOI2008]火星人prefix Splay+Hash+二分
    【bzoj2795】[Poi2012]A Horrible Poem Hash+分解质因数
  • 原文地址:https://www.cnblogs.com/dhcn/p/12485420.html
Copyright © 2011-2022 走看看