thrift installation problems and solutions of must see article

  • 2020-05-15 03:16:59
  • OfStack

1. boost must be installed. The latest stable version is 1.48.0.

1.1. Download first: http: / / sourceforge NET projects/boost/files/boost 1.48.0 /

Select the tar.gz package,
After downloading, I unzipped to /usr/local/boost_1_48: tar zxvf boost1.48.0-C /usr/local/boost_1_48

1.2. The installation process is a little different from the previous version. Just look at index in the built-in software package.

The main content involved in the installation of the two steps, very simple, into the level 1 directory:

$. / bootstrap. sh / / the default installation to the/usr/local/include/boost and/usr local/lib
$ ./b2 install

1.3 next, set the automatic import of environment variables:

With vim first create a file: / etc/profile d/boost sh, (if not performed using chmod a + x boost. sh set execute permissions).

Content as follows:

#! / bin sh # boost settings BOOST_ROOT = / opt boost_1_48 BOOST_INCLUDE = / usr/local/include/boost BOOST_LIB = / usr/local/lib export BOOST_ROOT BOOST_INCLUDE BOOST_LIB note: error while loading shared libraries: xxxx: cannot open file file or directory Reference: # find directory - name "xxxx * 2", will find the location of the directory in/etc/ld so. conf configuration file, the file records the compile time using dynamic link library path. 3. Then use the ldconfig command to make the configuration take effect.

2. Install libevent (select noblokingserver to install libevent, if there is an noblokingserver error, libevent is not installed).

The version I installed is the latest libevent 1.4.13:


wget http://monkey.org/~provos/libevent-1.4.13-stable.tar.gz
tar xvzf libevent-1.4.13-stable.tar.gz
cd libevent-1.4.13-stable
./configure && make
make install

3. The next step is to install thrift. I downloaded the latest version of thrift0.8.0 and entered the directory thrift0.8.0:

Because I only need to compile cpp, use the following command: (compiler options can reference http: / / www coder4. com archives / 2110).


./configure --with-cpp --with-boost --without-python --without-csharp --without-java --without-erlang --without-perl --without-php --without-php_extension --without-ruby --without-haskell --without-go
 
#make
make
 
#install
make install

If you still need to compile Java or any other language, you also need to install the other package in advance, specific reference http: / / wiki apache. org/thrift/ThriftRequirements:


C++
Boost 1.33.1+
libevent (optional, to build the nonblocking server)
zlib (optional)
Java
Java 1.5+
Apache Ant
Apache Ivy (recommended)
Apache Commons Lang (recommended)
SLF4J
C#: Mono 1.2.4+ (and pkg-config to detect it) or Visual Studio 2005+
Python 2.4+ (including header files for extension modules)
PHP 5.0+ (optionally including header files for extension modules)
Ruby 1.8+ (including header files for extension modules)
Erlang R12 (R11 works but not recommended)
Perl 5
Bit::Vector
Class::Accessor

Test 1 after installing thrift. Go to thrift under tutorial, compile the example given:

thrift-r --gen cpp tutorial

Some files will be generated in the gen-cpp directory. Then go to the CPP directory and compile:

make

Errors may be encountered: hton* declarations will not be visible to the compiler. This is an bug version of thrift. Some versions may not have this error, but the version I installed does. The solution:

Add -DHAVE_NETINET_IN_H at compile time using g++

So that we can make the preprocessor include into netinet/in h in thrift/protocol/TPrototol h, such hton * declarations will be visible to the compiler.

Here is a foreigner's explanation of bug:

TProtocol.h has the following lines which cause the compiler error when HAVE_NETINET_IN_H is not defined.
#ifdef HAVE_NETINET_IN_H #include < netinet/in.h > #endif
This might be a bug in the Thrift configure script which somehow skips the define.

For the above example, modify Makefile in the CPP folder and add the appropriate parameters to the compile line:

g++ -DHAVE_NETINET_IN_H -o CppServer -I${THRIFT_DIR} -I${BOOST_DIR} -I../gen-cpp -L${LIB_DIR} -lthrift CppServer.cpp ${GEN_SRC}

make, two executables, CppServer, CppClient.

At this point, thrift is installed.


Related articles: