I'm using Apache Thrift in a project. I generated code for the client. When I attempt to compile I get a set of similar linker errors:
undefined reference to `vtable for com::cybersecwise::thrift::ElasticFSServiceClient'
I got this same error when trying to implement the constructor using point scope resolution, but I was able to get rid of it by implementing it in the hpp file. That is, the following code:
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);
}
The problem now is I'm instantiating the class, and getting the undefined reference to vtable again.
I am aware that this error is associated when declarations are not defined for virtual functions. The thing is it seems to compile just fine as long as I don't instantiate the object.
ElasticFSThriftClient elasticFsClient("localhost", 9090);
It was actually quite simple. I forgot to add the generated code files when compiling the project.