Building thrift service on Windows 7

2020-07-27 03:18发布

问题:

What have I done?

I'm using Microsoft Visual Studio 2010

1) I downloaded libevent-2.0.16-stable ( download ) and I have put it to D:\sources

2) I have downloaded boostPro 1.47 ( from http://www.boostpro.com/download/ ) and I have installed it into D:\programs, selecting BoostPro Computing as mirror, checking Visual C++ 10.0 as Compiler, and as variants:

  • Multithreaded

  • Multithreaded debug

  • Multithreaded, static runtime

  • Multithreaded debug, static runtime

3) Then I have downloaded with SubVersion, thrift sources from here to D:\sources\thrift

4) Ok, now I went to D:\sources\thrift\lib\cpp and I opened libthrift.vcxproj with MSVC++ 10, included boost sources and libs ( D:\programs\boost\boost_1_47\ and D:\programs\boost\boost_1_47\lib\ ) and I have compiled it successfully.

5) I compiled .thrift tutorial's files ( thrift\tutorial\shared.thrift and thrift\tutorial\tutorial.thrift ) with his compiler

6) I have made a new project into MSVC++ 10, linked boost and thrift libs & sources, before generated, I have moved gen-cpp dir ( generated with Thrift Compiler before, and deleting *.skeleton.cpp files ) into the project, and this as main.cpp and compiled it successfully.

If you haven't found any boost lib, you can download them from here.

NOW, what's wrong? it seems all just perfect, but, when I start my application... PS: second line means "WSAStartup was not performed or WSAStartup's error".

Any ideas?

回答1:

Try inserting the following to the beginning of _tmain():

WSADATA wsa_data;
int result = WSAStartup(MAKEWORD(2, 2), &wsa_data);

if (0 != result)
{
    // Handle winsock load failure.
}
else
{
    // rest of `_tmain()` as you have it.
}


回答2:

With this patch Thrift works completely on windows!