c++ - Apache Thrift 未定义对生成代码中 vtable 的引用

标签 c++ debugging thrift

我在项目中使用 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 的 undefined reference 。

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

ElasticFSThriftClient elasticFsClient("localhost", 9090);

最佳答案

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

关于c++ - Apache Thrift 未定义对生成代码中 vtable 的引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53272602/

相关文章:

C++ 文件在第一行后停止读取

c++ - 如何设置、清除和切换单个位?

scala - Finagle + 节俭 : Count method invocations

python - Thrift:Python 服务器、Erlang 客户端错误... {thrift_socket_server,244,{child_error,function_clause,[]}}

c++ - 运行调试器时,带有空格字符的程序参数被 Eclipse 破坏

c - Thrift:是否可以仅使用 C(GLib)Thrift 库进行序列化?

c++ - pthreads_create() 返回非零值?

c++ - 我应该预先分配 std::stringstream 吗?

php - 如何调试 "FastCGI sent in stderr: Primary script unknown while reading response header from upstream"并找到实际的错误信息?

debugging - 崩溃后查看内核日志