【问题标题】:Apache Thrift undefined reference to vtable in Generated CodeApache Thrift 在生成的代码中未定义对 vtable 的引用
【发布时间】:2018-11-13 10:18:47
【问题描述】:

我在一个项目中使用 Apache Thrift。我为客户端生成了代码。当我尝试编译时,我得到一组类似的链接器错误:

undefined reference to `vtable for com::cybersecwise::thrift::ElasticFSServiceClient'

我在尝试使用点范围解析来实现构造函数时遇到了同样的错误,但我能够通过在 hpp 文件中实现它来摆脱它。即如下代码:

ElasticFSThriftClient(const string& server, int port) {
  stdcxx::shared_ptr<TTransport> socket(new TSocket(server, port));
  stdcxx::shared_ptr<TTransport> transport(new TBufferedTransport(socket));
  stdcxx::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
  ElasticFSServiceClient client(protocol);
}

现在的问题是我正在实例化类,并再次获得对 vtable 的未定义引用。

我知道当没有为虚函数定义声明时,会出现此错误。问题是只要我不实例化对象,它似乎编译得很好。

ElasticFSThriftClient elasticFsClient("localhost", 9090);

【问题讨论】:

    标签: c++ debugging thrift


    【解决方案1】:

    其实很简单。我在编译项目时忘记添加生成的代码文件。

    【讨论】:

    • 我正要问这个问题。
    猜你喜欢
    • 2013-02-23
    • 1970-01-01
    • 1970-01-01
    • 2012-08-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多