c++ - 无法加载, undefined symbol C++ 名称修改

标签 c++ extern

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

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 _ZTV15IteratorRegFileIteratorRegFile 的 vtable。因此,损坏的名称指的是 vtvable,而不是您的函数。

我做了一些搜索,发现了这个建议“你必须实现你的类的虚拟方法,因为那是编译器实际为它生成 vtable 的时候。”

您可以通过这种方式查看模块中有哪些符号:
nm 你的模块名称

我猜这个链接可能有帮助:

关于c++ - 无法加载, undefined symbol C++ 名称修改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10644471/

相关文章:

c++ - std::regex_constants::optimize 使用的优化技术

c - 外部代码不起作用

c++ - 使用 extern 声明创建头文件有什么意义?

c++ - 外部变量未定义

c++ - 现在有了内联变量,extern const仍然有用吗?

c++ - 如何正确返回对类成员的引用?

c++ - 单击路由器 C++ 标准库

c++ - 如何改进 Twitter 情绪分析器?

c++ - 有没有办法模拟 QSqlQuery?

c - 将外部变量重新定义为静态时没有错误