libphonenumber-csharp / cpp / README

C++ version of the libphonenumber project.

This is a port of the Java version.

This project uses some third-party code:
  - src/phonenumbers/utf/ sources come from lib9 which is also used in Go.


Building the library on GNU/Linux
---------------------------------
Requirements:
  - CMake build system
    http://www.cmake.org

    You can install it very easily on a Debian-based GNU/Linux distribution:
    $ sudo apt-get install cmake

    Additionally it is recommended you install the ccmake configuration tool:
    $ sudo apt-get install cmake-curses-gui

  - Protocol Buffers
    http://code.google.com/p/protobuf/
    Version 2.4 or more recent is required.

    You can install it very easily on a Debian-based GNU/Linux distribution:
    $ sudo apt-get install libprotobuf-dev

    Note: if your GNU/Linux distribution doesn't provide the needed package,
          please download and install it manually:
    $ tar xjf protobuf-2.4.tar.bz2
    $ cd protobuf-2.4
    $ ./configure && make && sudo make install

  - Google Test
    http://code.google.com/p/googletest/

    You can install it very easily on a Debian-based GNU/Linux distribution:
    $ sudo apt-get install libgtest-dev

  - RE2
    http://code.google.com/p/re2/

    You can install it very easily on Ubuntu Maverick and later:
    $ sudo apt-get install libre2-dev

    Otherwise if you use a Debian-based distribution you can fetch the Ubuntu
    package which should work:
    http://packages.ubuntu.com/maverick/libre2-dev

    If you want to install it manually:
    You need Mercurial to checkout its source code:
    $ sudo apt-get install mercurial

    Then checkout, build and install it:
    $ hg clone https://re2.googlecode.com/hg re2
    $ cd re2
    $ make test
    $ make install
    $ make testinstall

  - ICU
    Version 4.4 or more recent is required. It can be installed easily on Debian
    systems or be built from the most recent sources (currently 49.1.2).

    If you have a Debian-based distribution you can check which version of the
    ICU libraries is available by doing:
    $ apt-cache show libicu-dev
    And looking for the "Version:" string.

    If this is above 4.4 then you can just do:
    $ sudo apt-get install libicu-dev

    Otherwise you need to download the source tarball for the latest version
    from:
      http://site.icu-project.org/download
    And then extract it via:
    $ tar xzf icu4c-49_1_2-src.tgz

    Alternatively you can export the SVN repository to the current directory
    via:
    $ svn export http://source.icu-project.org/repos/icu/icu/tags/release-49-1-2/

    Having acquired the latest sources, make and install it via:
    $ cd icu/source
    $ ./configure && make && sudo make install

  - Boost
    Version 1.40 or more recent is required.

    You can install it very easily on a Debian-based GNU/Linux distribution:
    $ sudo apt-get install libboost1.40-dev libboost-thread1.40-dev

    Note: Boost Thread is the only library needed at link time.

How to build libphonenumber C++:
  $ cd libphonenumber/cpp
  $ mkdir build
  $ cd build
  $ cmake ..
  $ make

Troubleshooting CMake via ccmake:
  Follow these instructions if the build steps above don't work for you.

  - Incorrect protocol buffer library issues
    If the build process complains that the version of protoc being used is too
    old or that it cannot find the correct libprotobuf library, you may need to
    change the library path of the project.

    This issue should typically only occur in cases where you have two (or more)
    versions of the protocol buffer libraries installed on your system. This
    step assumes that you have already manually downloaded and installed the
    protocol buffer libraries into /usr/local (as described above).

    To make cmake use the manually installed version of the protocol buffer
    libraries, install cmake-curses-gui and use ccmake as follows.

    From within libphonenumber/cpp/build:
    $ ccmake .

    You should set the following values:
      PROTOBUF_INCLUDE_DIR         /usr/local/include
      PROTOBUF_LIB                 /usr/local/lib/libprotobuf.so
      PROTOC_BIN                   /usr/local/bin/protoc

    Now press 'c' then 'g' to configure the new parameters and exit ccmake.
    Finally regenerate the make files and rebuild via:
    $ cmake ..
    $ make

  - Protoc binary not executing properly
    If you still have issues with the protoc binary tool in /usr/local/bin not
    running correctly (cannot find libprotobuf.so.x) then you may need to
    configure the LD_LIBRARY_PATH. To do this, as a superuser, add the following
    file:
      /etc/ld.so.conf.d/libprotobuf.conf

    with the contents:
      # Use the manually installed version of the protocol buffer libraries.
      /usr/local/lib

    And then run:
      $ sudo chmod 644 /etc/ld.so.conf.d/libprotobuf.conf
      $ sudo ldconfig

  - Incorrect ICU library issues
    Similar to the protocol buffer library issue above, it is possible that your
    build may fail if you have two conflicting versions of the ICU libraries
    installed on your system. This step assumes that you have already manually
    downloaded and installed a recent version of the ICU libraries into
    /usr/local.

    Install and run the ccmake tool (as described above) and set the following
    values:
      ICU_I18N_INCLUDE_DIR         /usr/local/include
      ICU_I18N_LIB                 /usr/local/lib/libicui18n.so
      ICU_UC_INCLUDE_DIR           /usr/local/include
      ICU_UC_LIB                   /usr/local/lib/libicuuc.so

    Now press 'c' then 'g' to configure the new parameters and exit ccmake.
    Finally regenerate the make files and rebuild via:
    $ cmake ..
    $ make

Building the library on Windows (Visual Studio)
-----------------------------------------------
The library was tested with Visual Studio 2010.

You will need to manually fetch and install the following dependencies:
  - CMake (tested with v2.8.6):
    http://cmake.org/cmake/resources/software.html
    * Download and install the Win32 installer.

  - Boost (tested with v1.44) from BoostPro:
    http://www.boostpro.com/download/
    * Select all the variants and Boost DateTime and Boost Thread during the
      installation process.

  - GTest (tested with v1.6.0):
    http://code.google.com/p/googletest/downloads/list
    * Open msvc/gtest-md.sln with Visual Studio and build the whole solution.

  - ICU (MSVC binaries, tested with v4.8.1):
    http://site.icu-project.org/download/48#ICU4C-Download
    * Simply extract the archive.

  - Protocol Buffers:
    http://code.google.com/p/protobuf/downloads/list
    * Open vsprojects/protobuf.sln with Visual Studio and build the whole
      solution.

Then run cmake-gui and specify the path to the libphonenumber's cpp directory
and its build directory which must be created (e.g. cpp/build).

When clicking on "Configure", specify the appropriate Visual Studio version
(tested with 2010).

Then CMake will need your help to locate the dependencies. You will have to set
the following variables (this example assumes that you extracted the
dependencies to C:/).

GTEST_INCLUDE_DIR         C:/gtest-1.6.0/include
GTEST_LIB                 C:/gtest-1.6.0/msvc/gtest-md/Release/gtest.lib

ICU_I18N_INCLUDE_DIR      C:/icu/include
ICU_I18N_LIB              C:/icu/lib/icuin.lib

ICU_UC_INCLUDE_DIR        C:/icu/include
ICU_UC_LIB                C:/icu/lib/icuuc.lib

PROTOBUF_INCLUDE_DIR      C:/protobuf-2.4.1/src
PROTOBUF_LIB              C:/protobuf-2.4.1/vsprojects/Release/libprotobuf.lib
PROTOC_BIN                C:/protobuf-2.4.1/vsprojects/Release/protoc.exe

Then you can click on "Configure" again. CMake should have located all the
dependencies.
Then click on "Generate" to generate the appropriate Visual Studio project.
Then open cpp/build/libphonenumber.sln with Visual Studio and build the INSTALL
target.

As a result the library's headers and binaries should have been installed to
C:/Program Files/libphonenumber/.
Note that this path can be set by overriding the CMAKE_INSTALL_PREFIX variable
with cmake-gui.

Supported build parameters
--------------------------
  Build parameters can be specified invoking CMake with '-DKEY=VALUE' or using a
  CMake user interface (ccmake or cmake-gui).

  USE_ICU_REGEXP    = ON | OFF [ON]  -- Use ICU regexp engine.
  USE_LITE_METADATA = ON | OFF [OFF] -- Generates smaller metadata that doesn't
                                        include example numbers.
  USE_RE2           = ON | OFF [OFF] -- Use RE2.
  USE_STD_MAP       = ON | OFF [OFF] -- Force the use of std::map.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.