/usr/bin/ld: /tmp/ccIHWHTn.o: in function `Cdisk::Cdisk()‘:编译报错解决方案
Posted 土味儿大谢
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了/usr/bin/ld: /tmp/ccIHWHTn.o: in function `Cdisk::Cdisk()‘:编译报错解决方案相关的知识,希望对你有一定的参考价值。
问题:C++编译时发现一长串编译报错
$ vim ks.cpp
$ gcc -o ks ks.cpp
报错:
/usr/bin/ld: /tmp/ccIHWHTn.o: in function `Cdisk::Cdisk()':
ks.cpp:(.text+0xb5): undefined reference to `std::cout'
/usr/bin/ld: /tmp/ccIHWHTn.o: in function `Cdisk::~Cdisk()':
ks.cpp:(.text+0x163): undefined reference to `operator delete(void*, unsigned long)'
/usr/bin/ld: /tmp/ccIHWHTn.o: in function `Cdisk::dis_disk()':
ks.cpp:(.text+0x269): undefined reference to `std::cout'
...
/usr/bin/ld: ks.cpp:(.text+0x34b0): undefined reference to `std::ios_base::Init::~Init()'
/usr/bin/ld: /tmp/ccIHWHTn.o:(.data.rel.ro._ZTI5Cdisk[_ZTI5Cdisk]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
/usr/bin/ld: /tmp/ccIHWHTn.o:(.data.rel.local.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]+0x0): undefined reference to `__gxx_personality_v0'
collect2: error: ld returned 1 exit status
解决:增加编译参数 -lstdc++
$ gcc -o ks ks.cpp -lstdc++
编译问题解决,程序正常运行
以上是关于/usr/bin/ld: /tmp/ccIHWHTn.o: in function `Cdisk::Cdisk()‘:编译报错解决方案的主要内容,如果未能解决你的问题,请参考以下文章