代码之家  ›  专栏  ›  技术社区  ›  Kyu96

thrift&boost-具有初始值设定项,但类型不完整

  •  1
  • Kyu96  · 技术社区  · 6 年前

    我目前正在研究节俭的例子: 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)。这个错误的原因是什么?

    1 回复  |  直到 6 年前
        1
  •  2
  •   f4.    6 年前
    #include <boost/shared_ptr.hpp>
    

    也许它是在储蓄银行的报头上的某个地方申报的?