Trying to create a Thrift project with a C++ client, I could not complete the linking step. I then distilled my project to very basic functionality assuming a coding error, and could not link successfully. From there, I started from scratch with the CPP Tutorial, and have found the same error there. It appears that transport/TSocket has not successfully been built into the dynamic library.
My thrift file is called sample.thrift and declares a simple service called "Something", which contains only a ping() method.
My build step looks like:
g++ -lthrift -Wall -I/usr/local/include/thrift -stdlib=libstdc++ Something_client.cpp sample_constants.cpp sample_types.cpp Something.cpp -o Client
The result looks like:
Undefined symbols for architecture x86_64:
"apache::thrift::transport::TSocket::TSocket(std::string, int)", referenced from:
_main in Something_client-ca4a8d.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have replicated this error with separate compile/linking steps (as shown in the client section in http://wiki.apache.org/thrift/ThriftUsageC%2B%2B). The server compiles and links successfully, and the client compiles, but does not like. I have also replicated it via the given Makefile.
Aside from the TSocket, the rest of the file compiles and links successfully. The TBufferedTransport and TBinaryProtocol are linked with no issues when the TSocket is replaced with a dummy, e.g.:
Leading me to my conclusion that somehow the TSocket did not make it into my Thrift library. Are there any suggestions for what could be causing this and how it could be resolved?