如何在Windows中编译thrift?我有错误

时间:2014-04-09 15:42:57

标签: c++ visual-studio-2012 thrift

我试图在Visual Studio 2012中编译x64版本的thrift 我成功编译了它的依赖,libevent(使用VS 11 Win64代码生成器的cmake) 至于boost,我使用了预编译的二进制文件boost_1_55_0-msvc-11.0-64.exe(版本1.55.0_build2,Visual C ++ 2012 x64编译器)。
然后我在项目设置中更改了C ++文件夹:
包括文件夹:

  1. $(PROJECTDIR)\ SRC \
  2. $(PROJECTDIR)\ SRC \节俭\ Windows \
  3. C:\本地\ boost_1_55_0 \
  4. C:\ OpenSSL的-Win64的\包括\
  5. 库文件夹:

    1. C:\本地\ boost_1_55_0 \ lib64下-MSVC-11.0 \
    2. C:\源\ LIBEVENT主\ build64 \ lib中\调试\
    3. C:\ OpenSSL的-Win64的\ lib中\
    4. 然后我开始编译项目libthrift(在lib \ cpp \ subfolder中)后得到以下输出:

      1>------ Build started: Project: libthrift, Configuration: Debug x64 ------
      1>  WinFcntl.cpp
      1>  TWinsockSingleton.cpp
      1>  SocketPair.cpp
      1>  GetTimeOfDay.cpp
      1>  TTransportUtils.cpp
      1>  TTransportException.cpp
      1>  TSocket.cpp
      1>  TSimpleFileTransport.cpp
      1>  TServerSocket.cpp
      1>  TPipeServer.cpp
      1>  TPipe.cpp
      1>  THttpTransport.cpp
      1>  THttpServer.cpp
      1>src\thrift\transport\THttpServer.cpp(95): warning C4267: 'argument' : conversion from 'size_t' to 'uint32_t', possible loss of data
      1>  THttpClient.cpp
      1>  TFileTransport.cpp
      1>  TFDTransport.cpp
      1>  TBufferTransports.cpp
      1>  Thrift.cpp
      1>  TApplicationException.cpp
      1>  TThreadPoolServer.cpp
      1>  Generating Code...
      1>  Compiling...
      1>  TSimpleServer.cpp
      1>  TJSONProtocol.cpp
      1>  TDenseProtocol.cpp
      1>  TDebugProtocol.cpp
      1>  TBase64Utils.cpp
      1>  PeekProcessor.cpp
      1>c:\local\boost_1_55_0\boost/smart_ptr/shared_ptr.hpp(653): error C2668: '_wassert' : ambiguous call to overloaded function
      1>          C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\assert.h(28): could be 'void _wassert(const wchar_t *,const wchar_t *,unsigned int)'
      1>          C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\assert.h(28): or       'void apache::thrift::protocol::_wassert(const wchar_t *,const wchar_t *,unsigned int)'
      1>          while trying to match the argument list '(const wchar_t [8], const wchar_t [53], int)'
      1>          c:\local\boost_1_55_0\boost/smart_ptr/shared_ptr.hpp(652) : while compiling class template member function 'apache::thrift::transport::TTransport *boost::shared_ptr<T>::operator ->(void) const'
      1>          with
      1>          [
      1>              T=apache::thrift::transport::TTransport
      1>          ]
      1>          D:\Downloads\chrome\!source\thrift-0.9.1\lib\cpp\src\thrift/transport/TBufferTransports.h(231) : see reference to function template instantiation 'apache::thrift::transport::TTransport *boost::shared_ptr<T>::operator ->(void) const' being compiled
      1>          with
      1>          [
      1>              T=apache::thrift::transport::TTransport
      1>          ]
      1>          D:\Downloads\chrome\!source\thrift-0.9.1\lib\cpp\src\thrift/transport/TTransport.h(262) : see reference to class template instantiation 'boost::shared_ptr<T>' being compiled
      1>          with
      1>          [
      1>              T=apache::thrift::transport::TTransport
      1>          ]
      1>  Util.cpp
      1>  TimerManager.cpp
      1>  ThreadManager.cpp
      1>  BoostThreadFactory.cpp
      1>src\thrift\concurrency\BoostThreadFactory.cpp(101): error C2664: 'std::thread::id::id(const std::thread &)' : cannot convert parameter 1 from 'boost::thread::id' to 'const std::thread &'
      1>          Reason: cannot convert from 'boost::thread::id' to 'const std::thread'
      1>          No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
      1>src\thrift\concurrency\BoostThreadFactory.cpp(165): error C2664: 'std::thread::id::id(const std::thread &)' : cannot convert parameter 1 from 'boost::thread::id' to 'const std::thread &'
      1>          Reason: cannot convert from 'boost::thread::id' to 'const std::thread'
      1>          No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
      1>  BoostMutex.cpp
      1>  BoostMonitor.cpp
      1>  TAsyncChannel.cpp
      1>  Generating Code...
      

      第一个错误说在处理PeekProcessor.cpp时有两个不明确的_wassert函数调用。 _wassert来自BOOST_ASSERT宏内部的boost&#39; shared_ptr箭头操作符。第二个签名&#34; void apache :: thrift :: protocol :: _ wassert(const wchar_t *,const wchar_t *,unsigned int)&#34;看起来像shared_ptr.h包含在apache :: thrift :: protocol中,但我找不到。
      有人可以建议如何更正此错误吗?

      有人可以说出最后两个错误是什么以及如何纠正错误吗?

2 个答案:

答案 0 :(得分:0)

TProtocol.h

namespace apache { namespace thrift { namespace protocol {

using apache::thrift::transport::TTransport;

#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif

#ifndef __THRIFT_BYTE_ORDER
# if defined(BYTE_ORDER) && defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN)
#  define __THRIFT_BYTE_ORDER BYTE_ORDER
#  define __THRIFT_LITTLE_ENDIAN LITTLE_ENDIAN
#  define __THRIFT_BIG_ENDIAN BIG_ENDIAN
# else
#  include <boost/config.hpp>
#  include <boost/detail/endian.hpp>
#  define __THRIFT_BYTE_ORDER BOOST_BYTE_ORDER
#  ifdef BOOST_LITTLE_ENDIAN
#   define __THRIFT_LITTLE_ENDIAN __THRIFT_BYTE_ORDER
#   define __THRIFT_BIG_ENDIAN 0
#  else
#   define __THRIFT_LITTLE_ENDIAN 0
#   define __THRIFT_BIG_ENDIAN __THRIFT_BYTE_ORDER
#  endif
# endif
#endif

为:

#  include <boost/config.hpp>
#  include <boost/detail/endian.hpp>

namespace apache { namespace thrift { namespace protocol {

using apache::thrift::transport::TTransport;

#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif

#ifndef __THRIFT_BYTE_ORDER
# if defined(BYTE_ORDER) && defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN)
#  define __THRIFT_BYTE_ORDER BYTE_ORDER
#  define __THRIFT_LITTLE_ENDIAN LITTLE_ENDIAN
#  define __THRIFT_BIG_ENDIAN BIG_ENDIAN
# else

#  define __THRIFT_BYTE_ORDER BOOST_BYTE_ORDER
#  ifdef BOOST_LITTLE_ENDIAN
#   define __THRIFT_LITTLE_ENDIAN __THRIFT_BYTE_ORDER
#   define __THRIFT_BIG_ENDIAN 0
#  else
#   define __THRIFT_LITTLE_ENDIAN 0
#   define __THRIFT_BIG_ENDIAN __THRIFT_BYTE_ORDER
#  endif
# endif
#endif

答案 1 :(得分:0)

在Thrift 0.10.0中,代码已更新,不再看到此错误。 虽然VS项目文件仍然存在,但使用CMake可以更好地管理Windows上的构建。

有关构建步骤,请参阅Apache Thrift on Windows