是的,所以我试图编译我的程序,我收到以下错误:
/tmp/ccqeDaMs.o: In function `__static_initialization_and_destruction_0(int, int)':
arrr.cpp:(.text+0x4f): undefined reference to `std::ios_base::Init::Init()'
arrr.cpp:(.text+0x5e): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccqeDaMs.o: In function `__::___()':
arrr.cpp:(.text._ZN2__3___Ev[_ZN2__3___Ev]+0x12): undefined reference to `std::cout'
arrr.cpp:(.text._ZN2__3___Ev[_ZN2__3___Ev]+0x17): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/ccqeDaMs.o:(.eh_frame+0x6b): undefined reference to `__gxx_personality_v0'
collect2: error: ld returned 1 exit status
有关信息,请参阅我的代码:
#include <iostream>
class __ {
public:
__ ___() {std::cout<<"kill me"; return *this;}
};
class ____: public __ {
public:
____ _____(__ *______) {______->___().___();}
};
int main() {
____ _______;
__ ________;
_______._____(&________);
return -6;
}
我做错了什么?
答案 0 :(得分:2)
使用g++
编译和链接您的代码,而不是gcc
。 gcc
链接器不包含C ++库。
答案 1 :(得分:0)
您的程序使用保留标识符显示UB(保留以__
开头的标识符)。链接失败的足够原因,即使它因其他原因而失败。