我尝试在Visual Studio 2012中编译Thrift的x64版本。
我成功地编译了它的依赖项libevent(带有VS 11 Win64代码生成器的cmake)。
至于boost,我使用了预编译的二进制boost_1_55_0-msvc-11.0-64.exe(1.55.0_build2版本,Visual C ++ 2012 x64编译器)。
然后我在项目设置中更改了C ++文件夹:
包含文件夹:
$(ProjectDir)\ src \
$(ProjectDir)\ src \ thrift \ windows \
c:\ local \ boost_1_55_0 \
c:\ OpenSSL-Win64 \ include \
库文件夹:
c:\ local \ boost_1_55_0 \ lib64-msvc-11.0 \
c:\ source \ Libevent-master \ build64 \ lib \ Debug \
c:\ OpenSSL-Win64 \ lib \
然后,在我开始编译项目libthrift(在lib \ cpp \子文件夹中)之后,我得到以下输出:
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'shared_ptr箭头运算符内的BOOST_ASSERT宏构造而成。第二个签名“ void apache :: thrift :: protocol :: _ wassert(const wchar_t *,const wchar_t *,unsigned int)”看起来像shared_ptr.h包含在apache :: thrift :: protocol内,但我找不到位置。
有人可以建议如何纠正此错误吗?
有人可以告诉您最后两个错误是什么以及如何纠正它们?
最佳答案
协议
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
关于c++ - 如何在Windows中编译Thrift?我有错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22967589/