0

执行程序时出现以下错误:

E:无法加载libsim.so:libsim.so:未定义符号:_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();
   }

知道为什么编译器会修改函数以使 lib 不再找到它吗?

4

1 回答 1

1

如果您在 Linux 上使用 gcc 执行此操作:

根据 c++filt_ZTV15IteratorRegFilevtable for IteratorRegFile. 因此,损坏的名称指的是 vtvable,而不是您的函数。

我做了一些搜索并找到了这个建议"You must implement virtual methods of your class because that's when the compiler actually generates the vtable for it."

您可以通过这种方式检查模块中有哪些符号:
nm your-module-name

我想这个链接可能会有所帮助:

于 2012-05-18T04:50:51.287 回答