Mac OS x10.10 installation Thrift

Source: Internet
Author: User
Tags install homebrew

http://thrift.apache.org/docs/install/

One: Install the latest version (automatic installation)

The simplest is to install with the homebrew

    • Install Homebrew in Terminal input RUBY-E "$ (curl-fssl https://raw.github.com/Homebrew/homebrew/go/install)"

    • Install Thrift Brew Install Thrift

The thrift version installed with brew is 0.9, but the thrift version of our project is 0.8, so we have to unload it decisively.

Brew Uninstall Thrift. Go to the following second method of installing thrift

Two: manual installation of 0.8.0

Install dependencies first.

    • Install boost

Download: http://www.boost.org/

Command:./bootstrap.sh, which is used to generate the Bjam executable file, which is used to compile the boost library

Command: sudo./b2 threading=multi address-model=64 variant=release Stage Install

    • Installing Libevent

Download: http://libevent.org/

Command:./configure--prefix=/usr/local

Command: Make

Command: sudo make install

    • Installing Apache Thrift

Download: http://thrift.apache.org/

Compile command:./configure--prefix=/usr/local/--with-boost=/usr/local/lib--with-libevent=/usr/local/lib--without-ruby-- Without-python--without-perl--without-php

There are some irrelevant code genorater can not, or will have to error ...

Install command: sudo make install

Thrift-version can see if the installation was successful and the version

Thrift-0.8.0.tar.gz

When installing 8, you will encounter the following problems and resolve as follows:

The following is excerpted from the American Regiment Created by Cao Jiguang, last modified by Shing on October

Osx 10.9 is a relatively new system, starting with this version, the system default compiler changes from GCC to Clang (Gcc-v, which gives Clang hints).

The Thrift 0.8 code is relatively old and encounters some of the following problems with the new compiler.

Question 1:

Multiple source file error # include <tr1/functional>, file not found, change to # include <boost/tr1/functional.hpp> resolve.

The following files need to be modified:

    • Lib/cpp/src/concurrency/threadmanager.h line:24
    • Lib/cpp/src/async/tasyncchannel.h line:23
    • Lib/cpp/src/async/tasyncchannel.cpp line:21
    • Lib/cpp/src/async/tasyncprocessor.h line:23
    • Lib/cpp/src/async/tasyncbufferprocessor.h line:23

Cause: In my trial environment, this header file has the suffix name/usr/local/include/boost/tr1/functional.hpp

Question 2:

CPP test Code Test/benchmark.cpp compile failed, shared_ptr ambigous, replace shared_ptr with Boost::shared_ptr,

The error disappears.

Cause: Clang supports C + + 11, and its standard library comes with shared_ptr (std::shared_ptr, reference http://zh.cppreference.com/w/cpp/memory/shared_ptr)

Therefore, you need to explicitly specify a namespace.

Three: Testing

Let's write a helloworld.thrift to test the content as follows:

namespace Java Com.meituan.mobile.hotel.sc.demo

Service HelloWorldService {
String SayHello (1:string username)
}

Execute: Thrift-gen java helloworld.thrift will generate Gen-java/com/meituan/mobile/hotel/sc/demo/helloworldservice.java files in the sibling directory.

Mac OS x10.10 installation Thrift

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.