无法加载,未定义的符号C++名称重整

unable to load, undefined symbol C++ name mangling

本文关键字:C++ 符号 加载 未定义      更新时间:2023-10-16

我在执行程序时收到以下错误:

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_;

IteratorRegFile.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();
   }

知道为什么编译器要修改函数,以便库不再找到它吗?

如果你在带有 gcc 的 Linux 上执行此操作:

根据 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

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

  • 未定义的符号"vtable for ..."和"类型信息..."?
  • http://lists.apple.com/archives/darwin-development/2003/Sep/msg00273.html