http://thrift.apache.org/docs/install/
One: Install the latest version (automatic installation)
The simplest is to install with the homebrew
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.
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
Download: http://libevent.org/
Command:./configure--prefix=/usr/local
Command: Make
Command: sudo make install
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