저는 MySQL 5.5를 사용하고 있습니다. 플러그인은 약간의 정보를 얻기 위해 중고 인터페이스 서버를 쿼리해야합니다. 그때 함수 이름()의 주요 변경 및 플러그인 코드 파일로 추가mysql 플러그인에서 절약 기능을 사용할 수 있습니까?
#include "../../xxxx/gen-cpp/Xxxx.h"
#include <transport/TSocket.h>
#include <transport/TBufferTransports.h>
#include <protocol/TBinaryProtocol.h>
using namespace apache::thrift;
using namespace apache::thrift::protocol;
using namespace apache::thrift::transport;
using namespace ::za::co::xxxx;
int main(int argc, char **argv) {
boost::shared_ptr<TSocket> socket(new TSocket("localhost", 9090));
boost::shared_ptr<TTransport> transport(new TBufferedTransport(socket));
boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
XxxxServiceClient client(protocol);
transport->open();
client.getStatus();
transport->close();
return 0;
}
: 나는 기본적으로 서버에 연결을 열어 상태를 가져온 다음 연결을 닫습니다 중고품 클라이언트를 생성 main 함수에서 호출했습니다. 플러그인 코드가 잘 구축하지만지도는 지금 중고품 참조의 전체를 많이 포함하고 플러그인을로드하려고에,이 오류가 얻을 :
ERROR 1126 (HY000): Can't open shared library '/usr/lib/mysql/plugin/libxxxx.so' (errno: 13 undefined symbol: _ZTVN6apache6thrift9transport18TBufferedTransportE)
해결이 새로운 중고품 참조를 얻을 수있는 방법이 있나요을 플러그인 설치시? 위의 코드없이 설치되어 실행됩니다.
#include <mysql/plugin.h>
#include <mysql_version.h>
#include <protocol/TBinaryProtocol.h>
#include <transport/TSocket.h>
#include <transport/TTransportUtils.h>
#include "gen-cpp/Calculator.h"
using namespace apache::thrift;
using namespace apache::thrift::protocol;
using namespace apache::thrift::transport;
using namespace tutorial;
using namespace shared;
using namespace boost;
static int hello_world_plugin_init(void *p) {
shared_ptr<TTransport> socket(new TSocket("localhost", 9090));
shared_ptr<TTransport> transport(new TBufferedTransport(socket));
shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
CalculatorClient client(protocol);
transport->open();
client.ping();
transport->close();
return 0;
}
그리고이 메이크 :
BOOST_DIR = /usr/include/boost
MYSQL_DIR = /usr/include/mysql
THRIFT_DIR = /usr/local/include/thrift
LIB_DIR = /usr/local/lib
GEN_SRC = gen-cpp/SharedService.cpp gen-cpp/shared_types.cpp gen-cpp/tutorial_types.cpp gen-cpp/Calculator.cpp
DEFS = -DMYSQL_DYNAMIC_PLUGIN -DHAVE_NETINET_IN_H
default: hello_thrift.cc
g++ ${DEFS} -fPIC -shared -o libhellothrift.so -I${MYSQL_DIR} -I${THRIFT_DIR} -I${BOOST_DIR} -Igen-cpp -L${LIB_DIR} hello_thrift.cc ${GEN_SRC} -lthrift
이 나는 클라이언트 CppServer 공정에 전화를 만든 간단한 인사 세계 MySQL의 데몬 플러그인을 만들 수 있었던 드리프트 CPP 튜토리얼 코드를 사용