Building Google libphonenumber on Linux

I’m using CentOS 6.0 and following are the steps I’m using to build libphonenumber for C++.

1. Check out libphonenumber

$ svn checkout http://libphonenumber.googlecode.com/svn/trunk/ libphonenumber-read-only

2. Build and install cmake. (This is because libphonenumber requires cmake v2.8 or above, but the version comes with OS is 2.6.4)
Go to http://www.cmake.org and download the latest cmake source file, extract, and then build it.

$ tar zxvf cmake-2.8.7.tar.gz
$ cd cmake-2.8.7
$ ./configure
$ make
$ sudo make install

3. Build and install Protocol Buffers:
Go to http://code.google.com/p/protobuf/ and download source file, extract and build it.

$ tar jxvf protobuf-2.4.1.tar.bz2
$ cd protobuf-2.4.1
$ ./configure
$ make
$ sudo make install

4. Google Test (http://code.google.com/p/googletest/)
This is a little tricky to build and install. Finally, the steps I take is:

$ unzip gtest-1.6.0.zip
$ mkdir mybuild
$ cd mybuild
$ cmake -Dgtest_build_tests=ON ${GTEST_DIR}
$ cmake -G"Unix Makefiles" ..
$ make
$ sudo cp -r ../include/gtest /usr/local/include
$ sudo cp lib*.a /usr/local/lib

5. RE2 (http://code.google.com/p/re2/)
Check out the code and build it.

$ hg clone https://re2.googlecode.com/hg re2
$ cd re2
$ make test
$ sudo make install
$ sudo make testinstall

6. ICU (http://site.icu-project.org/download)
I used the prebuild file for RHEL6-32, and it seems to work well.

$ icu4c-4_8_1_1-RHEL6-i386.tgz

7. Install boost and boost-devel by yum

$ sudo yum install boost
$ sudo yum install boost-devel

8. Build libphonenumber C++:

$ cd libphonenumber/cpp
$ mkdir build
$ cd build
$ cmake ..
$ make

Finally, the libphonenumber.so will be appear in the build directory.

1 comment:

  1. > 4. Google Test
    $ unzip gtest-1.6.0.zip
    $ cd gtest-1.6.0
    $ ./configure
    $ mkdir mybuild
    $ cd mybuild
    $ cmake -Dgtest_build_tests=ON ..
    $ cmake -G"Unix Makefiles" ..
    $ make
    $ sudo cp -r ../include/gtest /usr/local/include
    $ sudo cp lib*.a /usr/local/lib

    > 5. RE2
    $ hg clone https://re2.googlecode.com/hg re2
    $ cd re2
    edit Makefile:
    LDFLAGS?=-pthread
    $ make
    $ make test
    $ sudo make install

    ReplyDelete