Thrift is a remote procedure call framework that was first developed by Facebook, and Facebook later contributed to Apache as an open source project. His homepage is http://thrift.apache.org/, on this website we can download project source files, Getting Started guide and so on.
Thrift is an open source project that provides the official download of all source programs, the user to use the thrift framework, and the need to compile the framework. The thrift project is not self-contained, and thrift also references several third-party libraries. So the process of compiling the framework is a bit more, and it adds some difficulty. Skilled programmers can easily resolve these references, and the newly-started programmer face may experience setbacks. Here's how to compile the Libthrift project in Vc++11.
The development environment I am using is Visual Studio 2012, and the version number for download thrift is 0.9.2. Thrift Visual Studio Project solution in the \lib\cpp folder, the solution contains two projects, and the following describes the compilation process for the Libthrift project.
1: As indicated in the thrift documentation, a boost library will be used, and a newer version can be downloaded to http://www.boost.org, and I have downloaded this version of Boost_1_54_0.
2: Change the header file of the thrift project to include the directory and replace the $boost\include\ with the actual BOOST library file directory.
3: Click Compile, there will be a compilation failure, prompted to find the Openssl\err.h file and other errors
There are two ways to solve the problem
A: Several source files that are used in the OpenSSL library file are excluded from the project, such as Tsslsocket.h,tsslsocket.cpp. These two files are secure sockets transport mechanisms that exclude them from remote procedure calls and disable this transport mechanism.
B: Download the OpenSSL library and open the Libthrift project to change the include path of the $OPENSLL. The header file under \include\ in the OpenSSL directory is: \.. \crypto\ ... The VC++11 compiler does not recognize this syntax, it needs to change the syntax of each header file to include "..." form. Can be changed manually, or in Linux with the command line and then copy back, or write a short program. As the following small C # program
1 if(args. Length! =1)2 {3Console.WriteLine ("Invalid argument");4 return;5 }6 7 if(! Directory.Exists (args[0]))8 {9Console.WriteLine ("The directory is not exist");Ten return; One } A - foreach(varFiinchDirectory.GetFiles (args[0]). Where (r = R.endswith (". h"))) - { the varStrText =File.readalltext (FI); - if(!strtext.startswith (@"#")) - { - varStrmodify =@"#include """+ StrText +@""""; + File.writealltext (FI, strmodify); - } + } A atConsole.WriteLine ("Convert successfully"); -Console.ReadLine ();
Through the above efforts, now Libthrift can be successfully compiled.
Compiling the Libthrift project with vc++11