ubuntu下 GCC編譯程式出現 undefined reference to `std::ios_base::Init::Init()'問題——gcc編譯C++程式碼
阿新 • • 發佈:2019-02-09
hello.o: In function `main':hello.cpp:(.text+0x41): undefined reference to `std::cin'
hello.cpp:(.text+0xd1): undefined reference to `std::cout'
hello.o: In function `__static_initialization_and_destruction_0(int, int)':hello.cpp:(.text+0x19e): undefined reference to `std::ios_base::Init::Init()'
hello.cpp:(.text +0x1a3): undefined reference to `std::ios_base::Init::~Init()'
hello.o: In function `std::istream_iterator<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, char, std::char_traits<char>, int>::~istream_iterator()':hello.cpp:(.text._ZNSt16istream_iteratorISscSt11char_traitsIcEiED2Ev[_ZNSt16istream_iteratorISscSt11char_traitsIcEiED5Ev] +0x10): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char>>::~basic_string()'
hello.o: In function `std::istream_iterator<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, char, std::char_traits<char >, int>::istream_iterator(std::basic_istream<char, std::char_traits<char>>&)':hello.cpp:(.text._ZNSt16istream_iteratorISscSt11char_traitsIcEiEC2ERSi[_ZNSt16istream_iteratorISscSt11char_traitsIcEiEC5ERSi]+0x24): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char>>::basic_string()'
hello.cpp:(.text._ZNSt16istream_iteratorISscSt11char_traitsIcEiEC2ERSi[_ZNSt16istream_iteratorISscSt11char_traitsIcEiEC5ERSi]+0x41): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char>>::~basic_string()'
hello.o: In function `std::istream_iterator<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, char, std::char_traits<char>, int>::istream_iterator()':hello.cpp:(.text._ZNSt16istream_iteratorISscSt11char_traitsIcEiEC2Ev[_ZNSt16istream_iteratorISscSt11char_traitsIcEiEC5Ev]+0x24): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char>>::basic_string()'
hello.o: In function `std::istream_iterator<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, char, std::char_traits<char>, int>::istream_iterator(std::istream_iterator<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, char, std::char_traits<char>, int>const&)':hello.cpp:(.text._ZNSt16istream_iteratorISscSt11char_traitsIcEiEC2ERKS2_[_ZNSt16istream_iteratorISscSt11char_traitsIcEiEC5ERKS2_]+0x2f): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char>>::basic_string(std::basic_string<char, std::char_traits<char>, std::allocator<char>>const&)'
hello.o: In function `std::istream_iterator<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, char, std::char_traits<char>, int>::_M_read()':hello.cpp:(.text._ZNSt16istream_iteratorISscSt11char_traitsIcEiE7_M_readEv[std::istream_iterator<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, char, std::char_traits<char>, int>::_M_read()]+0x29): undefined reference to `std::basic_ios<char, std::char_traits<char>>::operatorvoid*() const'
hello.cpp:(.text._ZNSt16istream_iteratorISscSt11char_traitsIcEiE7_M_readEv[std::istream_iterator<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, char, std::char_traits<char>, int>::_M_read()]+0x61): undefined reference to `std::basic_istream<char, std::char_traits<char>>& std::operator>><char, std::char_traits<char>, std::allocator<char>>(std::basic_istream<char, std::char_traits<char>>&, std::basic_string<char, std::char_traits<char>, std::allocator<char>>&)'
hello.cpp:(.text._ZNSt16istream_iteratorISscSt11char_traitsIcEiE7_M_readEv[std::istream_iterator<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, char, std::char_traits<char>, int>::_M_read()]+0x7f): undefined reference to `std::basic_ios<char, std::char_traits<char>>::operatorvoid*() const'
hello.o: In function `void std::__insertion_sort<__gnu_cxx::__normal_iterator<std::basic_string<char, std::char_traits<char>, std::allocator<char>>*, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>>(__gnu_cxx::__normal_iterator<std::basic_string<char, std::char_traits<char>, std::allocator<char>>*, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::basic_string<char, std::char_traits<char>,
……
hello.cpp:(.text+0xd1): undefined reference to `std::cout'
hello.o: In function `__static_initialization_and_destruction_0(int, int)':hello.cpp:(.text+0x19e): undefined reference to `std::ios_base::Init::Init()'
hello.cpp:(.text
hello.o: In function `std::istream_iterator<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, char, std::char_traits<char>, int>::~istream_iterator()':hello.cpp:(.text._ZNSt16istream_iteratorISscSt11char_traitsIcEiED2Ev[_ZNSt16istream_iteratorISscSt11char_traitsIcEiED5Ev]
hello.o: In function `std::istream_iterator<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, char, std::char_traits<char
hello.cpp:(.text._ZNSt16istream_iteratorISscSt11char_traitsIcEiEC2ERSi[_ZNSt16istream_iteratorISscSt11char_traitsIcEiEC5ERSi]+0x41): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char>>::~basic_string()'
hello.o: In function `std::istream_iterator<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, char, std::char_traits<char>, int>::istream_iterator()':hello.cpp:(.text._ZNSt16istream_iteratorISscSt11char_traitsIcEiEC2Ev[_ZNSt16istream_iteratorISscSt11char_traitsIcEiEC5Ev]+0x24): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char>>::basic_string()'
hello.o: In function `std::istream_iterator<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, char, std::char_traits<char>, int>::istream_iterator(std::istream_iterator<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, char, std::char_traits<char>, int>const&)':hello.cpp:(.text._ZNSt16istream_iteratorISscSt11char_traitsIcEiEC2ERKS2_[_ZNSt16istream_iteratorISscSt11char_traitsIcEiEC5ERKS2_]+0x2f): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char>>::basic_string(std::basic_string<char, std::char_traits<char>, std::allocator<char>>const&)'
hello.o: In function `std::istream_iterator<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, char, std::char_traits<char>, int>::_M_read()':hello.cpp:(.text._ZNSt16istream_iteratorISscSt11char_traitsIcEiE7_M_readEv[std::istream_iterator<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, char, std::char_traits<char>, int>::_M_read()]+0x29): undefined reference to `std::basic_ios<char, std::char_traits<char>>::operatorvoid*() const'
hello.cpp:(.text._ZNSt16istream_iteratorISscSt11char_traitsIcEiE7_M_readEv[std::istream_iterator<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, char, std::char_traits<char>, int>::_M_read()]+0x61): undefined reference to `std::basic_istream<char, std::char_traits<char>>& std::operator>><char, std::char_traits<char>, std::allocator<char>>(std::basic_istream<char, std::char_traits<char>>&, std::basic_string<char, std::char_traits<char>, std::allocator<char>>&)'
hello.cpp:(.text._ZNSt16istream_iteratorISscSt11char_traitsIcEiE7_M_readEv[std::istream_iterator<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, char, std::char_traits<char>, int>::_M_read()]+0x7f): undefined reference to `std::basic_ios<char, std::char_traits<char>>::operatorvoid*() const'
hello.o: In function `void std::__insertion_sort<__gnu_cxx::__normal_iterator<std::basic_string<char, std::char_traits<char>, std::allocator<char>>*, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>>(__gnu_cxx::__normal_iterator<std::basic_string<char, std::char_traits<char>, std::allocator<char>>*, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::basic_string<char, std::char_traits<char>,
……