Compiling the Libthrift project with vc++11

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.