Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/130.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ thrift cpp示例代码编译错误_C++_Reference_Client_Thrift - Fatal编程技术网

C++ thrift cpp示例代码编译错误

C++ thrift cpp示例代码编译错误,c++,reference,client,thrift,C++,Reference,Client,Thrift,我不习惯节俭。 我想我安装正确了。我有以下自由裁量权: luckyan315@ubuntu:~/code/thrift-0.8.0/tutorial/cpp$ ll /usr/local/lib/ total 11496 drwxr-xr-x 4 root root 4096 Mar 23 19:35 ./ drwxr-xr-x 10 root root 4096 Oct 12 22:27 ../ -rwxr-xr-x 1 root root 4100463 Mar 31

我不习惯节俭。 我想我安装正确了。我有以下自由裁量权:

luckyan315@ubuntu:~/code/thrift-0.8.0/tutorial/cpp$ ll /usr/local/lib/

total 11496
drwxr-xr-x  4 root root     4096 Mar 23 19:35 ./
drwxr-xr-x 10 root root     4096 Oct 12 22:27 ../
-rwxr-xr-x  1 root root  4100463 Mar 31 20:26 libthrift-0.8.0.so*
-rw-r--r--  1 root root  7256552 Mar 31 20:26 libthrift.a
-rwxr-xr-x  1 root root      991 Mar 31 20:26 libthrift.la*
lrwxrwxrwx  1 root root       18 Mar 23 19:35 libthrift.so -> libthrift-0.8.0.so*
-rwxr-xr-x  1 root root   160727 Mar 31 20:26 libthriftz-0.8.0.so*
-rw-r--r--  1 root root   218290 Mar 31 20:26 libthriftz.a
-rwxr-xr-x  1 root root      998 Mar 31 20:26 libthriftz.la*
lrwxrwxrwx  1 root root       19 Mar 23 19:35 libthriftz.so -> libthriftz-0.8.0.so*
然后我试着编译cppClient教程,但我有“未定义 参考“错误”如下:

luckyan315@ubuntu:~/code/thrift-0.8.0/tutorial/cpp$ sudo g++ -DHAVE_NETINET_IN_H -o Server -I/usr/local/include/thrift/ -I/usr/local/boost/include/boost-1_33_1/  -I../gen-cpp -L/usr/local/lib/ -lthrift CppServer.cpp ../gen-cpp/SharedService.cpp ../gen-cpp/shared_types.cpp ../gen-cpp/tutorial_types.cpp ../gen-cpp/Calculator.cpp
/tmp/cc7lnwSw.o: In function `main':
CppServer.cpp:(.text+0xd1): undefined reference to `apache::thrift::transport::TServerSocket::TServerSocket(int)'
CppServer.cpp:(.text+0x15f): undefined reference to `apache::thrift::server::TSimpleServer::serve()'
/tmp/cc7lnwSw.o: In function `apache::thrift::server::TSimpleServer::~TSimpleServer()':
CppServer.cpp:(.text._ZN6apache6thrift6server13TSimpleServerD2Ev[_ZN6apache6thrift6server13TSimpleServerD5Ev]+0xb): undefined reference to `vtable for apache::thrift::server::TSimpleServer'
/tmp/cc7lnwSw.o: In function `apache::thrift::transport::TBufferedTransport::TBufferedTransport(boost::shared_ptr<apache::thrift::transport::TTransport>)':
CppServer.cpp:(.text._ZN6apache6thrift9transport18TBufferedTransportC2EN5boost10shared_ptrINS1_10TTransportEEE[_ZN6apache6thrift9transport18TBufferedTransportC5EN5boost10shared_ptrINS1_10TTransportEEE]+0x17): undefined reference to `vtable for apache::thrift::transport::TBufferedTransport'
/tmp/cc7lnwSw.o: In function `apache::thrift::server::TSimpleServer::TSimpleServer<apache::thrift::TProcessor>(boost::shared_ptr<apache::thrift::TProcessor> const&, boost::shared_ptr<apache::thrift::transport::TServerTransport> const&, boost::shared_ptr<apache::thrift::transport::TTransportFactory> const&, boost::shared_ptr<apache::thrift::protocol::TProtocolFactory> const&, boost::enable_if<boost::is_convertible<apache::thrift::TProcessor*, apache::thrift::TProcessor*>::type, void*>::type)':
CppServer.cpp:(.text._ZN6apache6thrift6server13TSimpleServerC2INS0_10TProcessorEEERKN5boost10shared_ptrIT_EERKNS6_INS0_9transport16TServerTransportEEERKNS6_INSB_17TTransportFactoryEEERKNS6_INS0_8protocol16TProtocolFactoryEEENS5_9enable_ifINS5_14is_convertibleIPS7_PS4_E4typeEPvE4typeE[_ZN6apache6thrift6server13TSimpleServerC5INS0_10TProcessorEEERKN5boost10shared_ptrIT_EERKNS6_INS0_9transport16TServerTransportEEERKNS6_INSB_17TTransportFactoryEEERKNS6_INS0_8protocol16TProtocolFactoryEEENS5_9enable_ifINS5_14is_convertibleIPS7_PS4_E4typeEPvE4typeE]+0x3a): undefined reference to `vtable for apache::thrift::server::TSimpleServer'
/tmp/cc7lnwSw.o: In function `apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>::writeMessageBegin(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, apache::thrift::protocol::TMessageType, int)':
CppServer.cpp:(.text._ZN6apache6thrift8protocol16TBinaryProtocolTINS0_9transport10TTransportEE17writeMessageBeginERKSsNS1_12TMessageTypeEi[apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>::writeMessageBegin(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, apache::thrift::protocol::TMessageType, int)]+0x15): undefined reference to `apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>::VERSION_1'
/tmp/cc7lnwSw.o: In function `apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>::readMessageBegin(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, apache::thrift::protocol::TMessageType&, int&)':
CppServer.cpp:(.text._ZN6apache6thrift8protocol16TBinaryProtocolTINS0_9transport10TTransportEE16readMessageBeginERSsRNS1_12TMessageTypeERi[apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>::readMessageBegin(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, apache::thrift::protocol::TMessageType&, int&)]+0x33): undefined reference to `apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>::VERSION_MASK'
CppServer.cpp:(.text._ZN6apache6thrift8protocol16TBinaryProtocolTINS0_9transport10TTransportEE16readMessageBeginERSsRNS1_12TMessageTypeERi[apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>::readMessageBegin(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, apache::thrift::protocol::TMessageType&, int&)]+0x3d): undefined reference to `apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>::VERSION_1'
/tmp/ccBkDvwC.o: In function `shared::SharedServiceClient::recv_getStruct(shared::SharedStruct&)':
SharedService.cpp:(.text+0x6f3): undefined reference to `apache::thrift::TApplicationException::read(apache::thrift::protocol::TProtocol*)'
/tmp/ccBkDvwC.o: In function `shared::SharedServiceProcessor::process(boost::shared_ptr<apache::thrift::protocol::TProtocol>, boost::shared_ptr<apache::thrift::protocol::TProtocol>, void*)':
SharedService.cpp:(.text+0xb05): undefined reference to `apache::thrift::TApplicationException::write(apache::thrift::protocol::TProtocol*) const'
/tmp/ccBkDvwC.o: In function `shared::SharedServiceProcessor::process_fn(apache::thrift::protocol::TProtocol*, apache::thrift::protocol::TProtocol*, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, int, void*)':
SharedService.cpp:(.text+0xd87): undefined reference to `apache::thrift::TApplicationException::write(apache::thrift::protocol::TProtocol*) const'
/tmp/ccBkDvwC.o: In function `shared::SharedServiceProcessor::process_getStruct(int, apache::thrift::protocol::TProtocol*, apache::thrift::protocol::TProtocol*, void*)':
SharedService.cpp:(.text+0x1409): undefined reference to `apache::thrift::TApplicationException::write(apache::thrift::protocol::TProtocol*) const'
/tmp/ccLRxoVZ.o: In function `tutorial::CalculatorClient::recv_ping()':
Calculator.cpp:(.text+0x12af): undefined reference to `apache::thrift::TApplicationException::read(apache::thrift::protocol::TProtocol*)'
/tmp/ccLRxoVZ.o: In function `tutorial::CalculatorClient::recv_add()':
Calculator.cpp:(.text+0x173b): undefined reference to `apache::thrift::TApplicationException::read(apache::thrift::protocol::TProtocol*)'
/tmp/ccLRxoVZ.o: In function `tutorial::CalculatorClient::recv_calculate()':
Calculator.cpp:(.text+0x1c7b): undefined reference to `apache::thrift::TApplicationException::read(apache::thrift::protocol::TProtocol*)'
/tmp/ccLRxoVZ.o: In function `tutorial::CalculatorProcessor::process(boost::shared_ptr<apache::thrift::protocol::TProtocol>, boost::shared_ptr<apache::thrift::protocol::TProtocol>, void*)':
Calculator.cpp:(.text+0x227f): undefined reference to `apache::thrift::TApplicationException::write(apache::thrift::protocol::TProtocol*) const'
/tmp/ccLRxoVZ.o: In function `tutorial::CalculatorProcessor::process_ping(int, apache::thrift::protocol::TProtocol*, apache::thrift::protocol::TProtocol*, void*)':
Calculator.cpp:(.text+0x298e): undefined reference to `apache::thrift::TApplicationException::write(apache::thrift::protocol::TProtocol*) const'
/tmp/ccLRxoVZ.o: In function `tutorial::CalculatorProcessor::process_add(int, apache::thrift::protocol::TProtocol*, apache::thrift::protocol::TProtocol*, void*)':
Calculator.cpp:(.text+0x2f9b): undefined reference to `apache::thrift::TApplicationException::write(apache::thrift::protocol::TProtocol*) const'
/tmp/ccLRxoVZ.o: In function `tutorial::CalculatorProcessor::process_calculate(int, apache::thrift::protocol::TProtocol*, apache::thrift::protocol::TProtocol*, void*)':
Calculator.cpp:(.text+0x3609): undefined reference to `apache::thrift::TApplicationException::write(apache::thrift::protocol::TProtocol*) const'
collect2: ld returned 1 exit status
luckyan315@ubuntu:~/code/thrift-0.8.0/tutorial/cpp$sudo g++-DHAVE_NETINET_IN_H-o Server-I/usr/local/include/thrift/-I/usr/local/boost/include/boost-1_33_1/-I../gen cpp-L/usr/local/lib/-lthrift CppServer.cpp../gen cpp/SharedService.cpp../gen cpp/shared_types.cpp../gen cpp/gen cpp/tutorial_types.cpp../gen
/tmp/CC7LNWW.o:在函数“main”中:
CppServer.cpp:(.text+0xd1):对“apache::thrift::transport::TServerSocket::TServerSocket(int)”的未定义引用
CppServer.cpp:(.text+0x15f):对“apache::thrift::server::TSimpleServer::serve()”的未定义引用
/tmp/cc7lnwSw.o:在函数“apache::thrift::server::TSimpleServer::~TSimpleServer()”中:
CppServer.cpp:(.text.zn6apache6thrift6server13tsimpleserver2ev[zn6apache6thrift6server13tsimpleserver5ev]+0xb):对“vtable for apache::thrift::server::TSimpleServer”的未定义引用
/tmp/cc7lnwSw.o:在函数“apache::thrift::transport::TBufferedTransport::TBufferedTransport(boost::shared_ptr)”中:
CppServer.cpp:(.text. zn6pache6thrift9transport18tbufferedtransportc2en5boost10shared\u ptrINS1\u 10tttransportee[zn6pache6thrift9transport18tbufferedtransportc5boost10shared\u ptrINS1\u 10tttransportee]+0x17):对“vtable for apache::thrift::transport::tbufferedtransportee”的未定义引用
/tmp/cc7lnwSw.o:在函数“apache::thrift::server::TSimpleServer::TSimpleServer(boost::shared_ptr const&,boost::shared_ptr const&,boost::shared_ptr const&,boost::shared_ptr const&,boost::enable_if::type)”中:
CppServer.cpp:(.text.\u zn6pache6thrift6server13t实现服务器c2ins0\u 10tprocessoreerkn5boost10共享的ptrIT\u EERKNS6\u INS0\u传送服务器传送服务器传送服务器传送工厂EERKNS6\u INS0\u 8协议传送工厂eens5\u启用\u 4\u 4\u可转换的PS7\u类型[\uzn6pache6thrift6server13tsimpleServerc5insu10tprocessoreerkn5boost10共享的ptrIT-EERKNS6-insu-transport6tserverkns6-insu-insu-insu-insu-transportfactoryeerkns6-insu-insu-8协议协议协议工厂eens5\u-ifINS5\u-14是可转换的ps7\u-PS4\u-type-epve4+0x3a]:未定义的对“可用于apache::节俭::服务器”的引用
/tmp/cc7lnwSw.o:在函数“apache::thrift::protocol::TBinaryProtocolT::writeMessageBegin(std::basic_string const&,apache::thrift::protocol::TMessageType,int)”中:
CppServer.cpp:(.text. zn6pache6thrift8protocol16tbinaryprotocoltins0	9transport10tttransporte17writemessagebeginerkssns112tmessagetypei[apache::thrift::protocolt::TBinaryProtocolT::writeMessageBegin(std::basic_string const&,apache::thrift::protocol::TMessageType,int)]+0x15):对“apache::thrift::protocol::TBinaryProtocolT::VERSION_1”的未定义引用
/tmp/cc7lnwSw.o:在函数“apache::thrift::protocol::TBinaryProtocolT::readMessageBegin(std::basic_string&,apache::thrift::protocol::TMessageType&,int&)”中:
CppServer.cpp:(.text.\u zn6pache6thrift8protocol16tbinaryprotocoltins0\u 9transport10tttransporte16readmessagebeginerstrns1\u 12tmessagetyperi[apache::thrift::protocol::TBinaryProtocolT::readMessageBegin(std::basic_string&,apache::thrift::protocol::TMessageType&,int&)]+0x33):对“apache::thrift::protocol::TBinaryProtocolT::VERSION\u MASK”的未定义引用
CppServer.cpp:(.text.\u zn6pache6thrift8protocol16tbinaryprotocoltins0\u 9transport10tttransporte16readmessagebeginerstrns1\u 12tmessagetyperi[apache::thrift::protocol::TBinaryProtocolT::readMessageBegin(std::basic_string&,apache::thrift::protocol::TMessageType&,int&)]+0x3d):对“apache::thrift::protocol::TBinaryProtocolT::VERSION_1”的未定义引用
/tmp/ccBkDvwC.o:在函数“shared::SharedServiceClient::recv_getStruct(shared::SharedStruct&)”中:
SharedService.cpp:(.text+0x6f3):对“apache::thrift::TApplicationException::read(apache::thrift::protocol::TProtocol*)”的未定义引用
/tmp/ccBkDvwC.o:在函数“shared::SharedServiceProcessor::process(boost::shared_ptr,boost::shared_ptr,void*)”中:
SharedService.cpp:(.text+0xb05):对“apache::thrift::TApplicationException::write(apache::thrift::protocol::TProtocol*)常量”的未定义引用
/tmp/ccBkDvwC.o:在函数“shared::SharedServiceProcessor::process_fn(apache::thrift::protocol*,apache::thrift::protocol::TProtocol*,std::basic_string&,int,void*)”中:
SharedService.cpp:(.text+0xd87):对“apache::thrift::TApplicationException::write(apache::thrift::protocol::TProtocol*)常量”的未定义引用
/tmp/ccBkDvwC.o:在函数“shared::SharedServiceProcessor::process_getStruct(int,apache::thrift::protocol::TProtocol*,apache::thrift::protocol::TProtocol*,void*)”中:
SharedService.cpp:(.text+0x1409):对“apache::thrift::TApplicationException::write(apache::thrift::protocol::TProtocol*)常量”的未定义引用
/tmp/ccLRxoVZ.o:在函数“tutorial::CalculatorClient::recv_ping()”中:
Calculator.cpp:(.text+0x12af):对“apache::thrift::TApplicationException::read(apache::thrift::protocol::TProtocol*)”的未定义引用
/tmp/ccLRxoVZ.o:在函数“tutorial::CalculatorClient::recv_add()”中:
Calculator.cpp:(.text+0x173b):对“apache::thrift::TApplicationException::read(apache::thrift::protocol::TProtocol*)”的未定义引用
/tmp/ccLRxoVZ.o:在函数“tutorial::CalculatorClient::recv_calculate()”中:
Calculator.cpp:(.text+0x1c7b):对“apache::thrift::TApplicationException::read(apache::thrift::protocol::TProtocol*)”的未定义引用
/tmp/ccLRxoVZ.o:在函数“tutorial::CalculatorProcessor::process(boost::shared_ptr,boost::shared_ptr,void*)”中:
Calculator.cpp:(.text+0x227f):对“apache::thrift::TApplicationException::write(apache::thrift::protocol::TProtocol*)常量”的未定义引用
/tmp/ccLRxoVZ.o:在函数“tutorial::CalculatorProcessor::process_ping(int,apache::thrift::protocol*,apache::thrift::protocol::TProtocol*,void*)”中:
Calculator.cpp:(.text+0x298e):未定义的引用
THRIFT_VER =thrift-0.8.0
USR_DIR    =${HOME}/usr
THRIFT_DIR =${USR_DIR}/${THRIFT_VER}
INCS_DIRS  =-I${USR_DIR}/include -I${THRIFT_DIR}/include/thrift
LIBS_DIRS  =-L${USR_DIR}/lib -L${USR_DIR}/${THRIFT_VER}/lib
CPP_DEFS   =-D=HAVE_CONFIG_H
CPP_OPTS   =-Wall -O2
LIBS       =-lthrift

GEN_SRC    = ../gen-cpp/SharedService.cpp  \
             ../gen-cpp/shared_types.cpp   \
             ../gen-cpp/tutorial_types.cpp \
             ../gen-cpp/Calculator.cpp
GEN_INC    = -I../gen-cpp

default: server client

server: CppServer.cpp
    g++ ${CPP_OPTS} ${CPP_DEFS} -o CppServer ${GEN_INC} ${INCS_DIRS} CppServer.cpp ${GEN_SRC} ${LIBS_DIRS} ${LIBS}

client: CppClient.cpp
    g++ ${CPP_OPTS} ${CPP_DEFS} -o CppClient ${GEN_INC} ${INCS_DIRS} CppClient.cpp ${GEN_SRC} ${LIBS_DIRS} ${LIBS}

clean:
    $(RM) -r CppClient CppServer
#!/bin/bash
THRIFT_VER=thrift-0.8.0
USR_DIR=${HOME}/usr
THRIFT_DIR=${USR_DIR}/${THRIFT_VER}
export LD_LIBRARY_PATH=${THRIFT_DIR}/lib:${LD_LIBRARY_PATH}
exec $1
brew install boost
brew install thrift
cd ./thrift-0.8.0/tutorial
thrift --gen cpp ./tutorial.thrift
cd ./cpp
THRIFT_VER =thrift/0.8.0
USR_DIR    =/usr/local/Cellar
THRIFT_DIR =${USR_DIR}/${THRIFT_VER}
INCS_DIRS  =-I${USR_DIR}/include -I${THRIFT_DIR}/include/thrift -I${USR_DIR}/boost/1.49.0/include/boost
LIBS_DIRS  =-L${USR_DIR}/${THRIFT_VER}/lib
CPP_DEFS   =-D=HAVE_CONFIG_H
CPP_OPTS   =-Wall -O2
LIBS       =-lthrift

GEN_SRC    = ../gen-cpp/SharedService.cpp  \
             ../gen-cpp/shared_types.cpp   \
             ../gen-cpp/tutorial_types.cpp \
             ../gen-cpp/Calculator.cpp
GEN_INC    = -I../gen-cpp

default: server client

server: CppServer.cpp
        g++ ${CPP_OPTS} ${CPP_DEFS} -o CppServer ${GEN_INC} ${INCS_DIRS} CppServer.cpp ${GEN_SRC} ${LIBS_DIRS} ${LIBS}

client: CppClient.cpp
        g++ ${CPP_OPTS} ${CPP_DEFS} -o CppClient ${GEN_INC} ${INCS_DIRS} CppClient.cpp ${GEN_SRC} ${LIBS_DIRS} ${LIBS}

clean:
        $(RM) -r CppClient CppServer
make
./CppServer
./CppClient
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/Cellar/thrift/0.8.0/lib/pkgconfig/
-std=c++11