Install, compile, and test Thrift in Ubuntu

Source: Internet
Author: User
1. Thrift concept Thrift is a software framework used for scalable and cross-language service development. It integrates powerful software stacks and code generation engines to build in C ++, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C #, Cocoa, javaScript, Node. js, Smalltalk, and andOCaml programming languages are seamlessly integrated and efficient services. T

1. Thrift Concept

Thrift is a software framework used to develop scalable and cross-language services. It integrates powerful software stacks and code generation engines to build in C ++, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C #, Cocoa, javaScript, Node. javascript, Smalltalk, and OCaml programming languages are seamlessly integrated and efficient services.

Thrift was initially developed by facebook. It opened source code in April and entered the apache incubator in May.

Thrift allows you to define data types and service interfaces in a simple definition file. As an input file, the compiler generates code to easily generate a seamless cross-programming language for RPC client and server communication.

Here, thrift serves almost the same purpose as webservice. webservice uses xml for file transmission. The file is too large and inefficient. thrift uses binary data to improve efficiency!

2. Install and compile Thrift Installing and Compiling

Operating System: Ubuntu 8.0 +

Thrift package: thrift-0.7.0.tar.gz

:

Free onHttp://linux.linuxidc.com/

Both the user name and password areWww.linuxidc.com

The specific download directory is inInstall, compile, and test Thrift in/pub/2011/12/25/Ubuntu environment/

Specific installation process:

① Required packages installation support packages

Sudo apt-get install libboost-dev libboost-test-dev libboost-program-options-dev libevent-dev automake libtool flex bison pkg-config g ++ libssl-dev

② Tar-xvf thrift-0.7.0.tar.gz decompression File

③ Cd thrift-0.7.0 go to the Thrift installation home directory

④./Configure (there may be insufficient permissions. Please modify the File Permission sudo chmod 777 configure)

⑤ Sudo make

⑥ Sudo make install

Test whether the installation and compilation are successful:

Enter thrift on the terminal to display the following information,

OK, install thrift success.

Usage: thrift [options] file

Options:

-Version Print the compiler version

-O dir Set the output directory for gen-* packages

(Default: current directory)

-I dir Add a directory to the list of directories

Searched for include directives \

-Nowarn Suppress all compiler warnings (BAD !)

....

7. Compiling Thrift supports Java-related Jar files

Cd./lib/java

Then compile ant (If ant is not installed, sudo apt-get install ant. What is ant? Similar to c ++ make)

A build folder is generated, which stores jar packages supported by Thrift in JAVA.

3. Thrift Tutorial (for java) test Tutorial

To use Thrift Tutorial, follow these steps:

Cd ../tutorial enter the tutorial folder that comes with Thrift

Thrift-r -- gen java tutorial. thrift generate gen-java directory

Cd java

Then compile ant to generate relevant java files

Now you can run the demo for testing ~

Enable server./assumerver &

Open another terminal and simulate client access./JavaClient

Running result

1. service end:

2. Client:

Related Article

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.