在执行我的程序时出现以下错误:
E:Unable to load libsim.so: libsim.so: undefined symbol: _ZTV15IteratorRegFile
在 sim.cpp 中有 s.th.喜欢
//IteratorRegFileIs is a wrapper that calls the constructor for IteratorRegFile
Fwk::Ptr<IteratorRegFile> iteratorRegFile_ = IteratorRegFile::IteratorRegFileIs( "RF" );
void init(){
SparseArrayInt64 *sparse_array = new SparseArrayInt64(segID);
}
在 SparseArrayInt64.cpp 中:
extern Fwk::Ptr<IteratorRegFile> iteratorRegFile_;
迭代器RegFile.h:
public:
static IteratorRegFile::ValidPtr IteratorRegFileIs(Tac::Name _name) {
IteratorRegFile * m = new IteratorRegFile(_name);
m->referencesDec(1);
return m;
}
protected:
IteratorRegFile( const IteratorRegFile& );
explicit IteratorRegFile(Tac::Name _name): Tac::Entity(_name),
index_(0) {
handleInit();
}
知道为什么编译器会破坏函数以致库无法再找到它吗?
最佳答案
如果您在 Linux 上使用 gcc 执行此操作:
根据 c++filt _ZTV15IteratorRegFile
是 IteratorRegFile 的 vtable
。因此,损坏的名称指的是 vtvable,而不是您的函数。
我做了一些搜索,发现了这个建议“你必须实现你的类的虚拟方法,因为那是编译器实际为它生成 vtable 的时候。”
您可以通过这种方式查看模块中有哪些符号:
nm 你的模块名称
我猜这个链接可能有帮助:
关于c++ - 无法加载, undefined symbol C++ 名称修改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10644471/