gpt4 book ai didi

c++ - thrift & boost - 有初始化器但类型不完整

转载 作者:行者123 更新时间:2023-11-30 03:22:33 25 4
gpt4 key购买 nike

我目前正在使用 Thrift 示例:Click

我创建的以下测试代码无法编译。

#include <thrift/transport/TSocket.h>
#include <thrift/transport/TBufferTransports.h>
#include <thrift/protocol/TBinaryProtocol.h>

using namespace apache::thrift;
using namespace apache::thrift::protocol;
using namespace apache::thrift::transport;

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));

return 0;
}

尝试编译时,出现以下异常:

/opt/JetBrains/apps/CLion/ch-0/181.5087.36/bin/cmake/bin/cmake --build /home/user/Documents/Projects/VerteilteSysteme/Insurer/cmake-build-debug --target Insurer -- -j 2
Scanning dependencies of target Insurer
[ 50%] Building CXX object CMakeFiles/Insurer.dir/main.cpp.o
/home/user/Documents/Projects/VerteilteSysteme/Insurer/main.cpp: In function ‘int main(int, char**)’:
/home/user/Documents/Projects/VerteilteSysteme/Insurer/main.cpp:10:38: error: variable ‘boost::shared_ptr<apache::thrift::transport::TSocket> socket’ has initializer but incomplete type
boost::shared_ptr<TSocket> socket(new TSocket("localhost", 9090));
^
/home/user/Documents/Projects/VerteilteSysteme/Insurer/main.cpp:11:44: error: variable ‘boost::shared_ptr<apache::thrift::transport::TTransport> transport’ has initializer but incomplete type
boost::shared_ptr<TTransport> transport(new TBufferedTransport(socket));
^
/home/user/Documents/Projects/VerteilteSysteme/Insurer/main.cpp:12:42: error: variable ‘boost::shared_ptr<apache::thrift::protocol::TProtocol> protocol’ has initializer but incomplete type
boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
^
make[3]: *** [CMakeFiles/Insurer.dir/build.make:63: CMakeFiles/Insurer.dir/main.cpp.o] Error 1
make[2]: *** [CMakeFiles/Makefile2:68: CMakeFiles/Insurer.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:80: CMakeFiles/Insurer.dir/rule] Error 2
make: *** [Makefile:118: Insurer] Error 2

我仔细检查过,boost 和 thrift 都已正确安装在我的系统上。 (ArchLinux x64)。这个错误的原因是什么?

最佳答案

#include <boost/shared_ptr.hpp>

也许它是在 thrift 的 header 中的某处预先声明的?

关于c++ - thrift & boost - 有初始化器但类型不完整,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51049150/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com