在windows下使用C++和Thrift开发客户端程序与HBase进行通信,总是实现不了。
已经安装了thrift所依赖的boost,libevent,openssl底层东西,也成功编译出了libthrift.lib和libthriftnb.lib两个lib库。
客户端程序添加引用如下:
1.在C++/常规/附加包含目录中添加对头文件的引用:C:\openssl\include;C:\libevent\include;C:\boost\include;E:\HBase\thrift-0.9.3\lib\cpp\src;E:\HBase\thrift-0.9.3\lib\cpp\src\thrift。
2.在链接器/常规/附加库目录中添加库文件目录:C:\openssl\out32dll;C:\libevent\libs;C:\boost\libs;E:\HBase\thrift-0.9.3\lib\cpp\Debug
3.在链接器/输入/附加依赖项中添加对libthrift.lib和libthriftnb.lib两个lib库的引用
但是在创建客户端引用的过程中总是报错:
错误 2 error LNK2019: 无法解析的外部符号 "public: void __thiscall apache::thrift::TOutput::perror(char const *,int)" (?perror@TOutput@thrift@apache@@QAEXPBDH@Z),该符号在函数 "protected: void __thiscall apache::thrift::transport::TSocket::openConnection(struct addrinfo *)" (?openConnection@TSocket@transport@thrift@apache@@IAEXPAUaddrinfo@@@Z) 中被引用 E:\HBase\thrift-0.9.3\lib\cpp\CppDemo\libthrift.lib(TSocket.obj) CppDemo
错误 3 error LNK2019: 无法解析的外部符号 "public: static class std::basic_string,class std::allocator > __cdecl apache::thrift::TOutput::strerror_s(int)" (?strerror_s@TOutput@thrift@apache@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z),该符号在函数 "public: __thiscall apache::thrift::transport::TTransportException::TTransportException(enum apache::thrift::transport::TTransportException::TTransportExceptionType,class std::basic_string,class std::allocator > const &,int)" (??0TTransportException@transport@thrift@apache@@QAE@W4TTransportExceptionType@0123@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) 中被引用 E:\HBase\thrift-0.9.3\lib\cpp\CppDemo\libthrift.lib(TSocket.obj) CppDemo
程序代码如下:
#include "stdafx.h"
#include
#include
#include
#include
#include
#include
using namespace std;
using namespace ::apache::thrift;
using namespace ::apache::thrift::protocol;
using namespace ::apache::thrift::transport;
using namespace ::apache::thrift::server;
using boost::shared_ptr;
int _tmain(int argc, _TCHAR* argv[])
{
boost::shared_ptr socket(new TSocket("127.0.0.1", 9090));
return 0;
}
各位大神,可有办法?急...