1 C++ version of the libphonenumber project.
3 This is a port of the Java version.
5 This project uses some third-party code:
6 - src/phonenumbers/utf/ sources come from lib9 which is also used in Go.
9 Building the library on GNU/Linux
10 ---------------------------------
15 You can install it very easily on a Debian-based GNU/Linux distribution:
16 $ sudo apt-get install cmake
18 Additionally it is recommended you install the ccmake configuration tool:
19 $ sudo apt-get install cmake-curses-gui
22 http://code.google.com/p/protobuf/
23 Version 2.4 or more recent is required.
25 You can install it very easily on a Debian-based GNU/Linux distribution:
26 $ sudo apt-get install libprotobuf-dev
28 Note: if your GNU/Linux distribution doesn't provide the needed package,
29 please download and install it manually:
30 $ tar xjf protobuf-2.4.tar.bz2
32 $ ./configure && make && sudo make install
35 http://code.google.com/p/googletest/
37 You can install it very easily on a Debian-based GNU/Linux distribution:
38 $ sudo apt-get install libgtest-dev
41 http://code.google.com/p/re2/
43 You can install it very easily on Ubuntu Maverick and later:
44 $ sudo apt-get install libre2-dev
46 Otherwise if you use a Debian-based distribution you can fetch the Ubuntu
47 package which should work:
48 http://packages.ubuntu.com/maverick/libre2-dev
50 If you want to install it manually:
51 You need Mercurial to checkout its source code:
52 $ sudo apt-get install mercurial
54 Then checkout, build and install it:
55 $ hg clone https://re2.googlecode.com/hg re2
62 Version 4.4 or more recent is required. It can be installed easily on Debian
63 systems or be built from the most recent sources (currently 49.1.2).
65 If you have a Debian-based distribution you can check which version of the
66 ICU libraries is available by doing:
67 $ apt-cache show libicu-dev
68 And looking for the "Version:" string.
70 If this is above 4.4 then you can just do:
71 $ sudo apt-get install libicu-dev
73 Otherwise you need to download the source tarball for the latest version
75 http://site.icu-project.org/download
76 And then extract it via:
77 $ tar xzf icu4c-49_1_2-src.tgz
79 Alternatively you can export the SVN repository to the current directory
81 $ svn export http://source.icu-project.org/repos/icu/icu/tags/release-49-1-2/
83 Having acquired the latest sources, make and install it via:
85 $ ./configure && make && sudo make install
88 Version 1.40 or more recent is required.
90 You can install it very easily on a Debian-based GNU/Linux distribution:
91 $ sudo apt-get install libboost1.40-dev libboost-thread1.40-dev
93 Note: Boost Thread is the only library needed at link time.
95 How to build libphonenumber C++:
96 $ cd libphonenumber/cpp
102 Troubleshooting CMake via ccmake:
103 Follow these instructions if the build steps above don't work for you.
105 - Incorrect protocol buffer library issues
106 If the build process complains that the version of protoc being used is too
107 old or that it cannot find the correct libprotobuf library, you may need to
108 change the library path of the project.
110 This issue should typically only occur in cases where you have two (or more)
111 versions of the protocol buffer libraries installed on your system. This
112 step assumes that you have already manually downloaded and installed the
113 protocol buffer libraries into /usr/local (as described above).
115 To make cmake use the manually installed version of the protocol buffer
116 libraries, install cmake-curses-gui and use ccmake as follows.
118 From within libphonenumber/cpp/build:
121 You should set the following values:
122 PROTOBUF_INCLUDE_DIR /usr/local/include
123 PROTOBUF_LIB /usr/local/lib/libprotobuf.so
124 PROTOC_BIN /usr/local/bin/protoc
126 Now press 'c' then 'g' to configure the new parameters and exit ccmake.
127 Finally regenerate the make files and rebuild via:
131 - Protoc binary not executing properly
132 If you still have issues with the protoc binary tool in /usr/local/bin not
133 running correctly (cannot find libprotobuf.so.x) then you may need to
134 configure the LD_LIBRARY_PATH. To do this, as a superuser, add the following
136 /etc/ld.so.conf.d/libprotobuf.conf
139 # Use the manually installed version of the protocol buffer libraries.
143 $ sudo chmod 644 /etc/ld.so.conf.d/libprotobuf.conf
146 - Incorrect ICU library issues
147 Similar to the protocol buffer library issue above, it is possible that your
148 build may fail if you have two conflicting versions of the ICU libraries
149 installed on your system. This step assumes that you have already manually
150 downloaded and installed a recent version of the ICU libraries into
153 Install and run the ccmake tool (as described above) and set the following
155 ICU_I18N_INCLUDE_DIR /usr/local/include
156 ICU_I18N_LIB /usr/local/lib/libicui18n.so
157 ICU_UC_INCLUDE_DIR /usr/local/include
158 ICU_UC_LIB /usr/local/lib/libicuuc.so
160 Now press 'c' then 'g' to configure the new parameters and exit ccmake.
161 Finally regenerate the make files and rebuild via:
165 Building the library on Windows (Visual Studio)
166 -----------------------------------------------
167 The library was tested with Visual Studio 2010.
169 You will need to manually fetch and install the following dependencies:
170 - CMake (tested with v2.8.6):
171 http://cmake.org/cmake/resources/software.html
172 * Download and install the Win32 installer.
174 - Boost (tested with v1.44) from BoostPro:
175 http://www.boostpro.com/download/
176 * Select all the variants and Boost DateTime and Boost Thread during the
177 installation process.
179 - GTest (tested with v1.6.0):
180 http://code.google.com/p/googletest/downloads/list
181 * Open msvc/gtest-md.sln with Visual Studio and build the whole solution.
183 - ICU (MSVC binaries, tested with v4.8.1):
184 http://site.icu-project.org/download/48#ICU4C-Download
185 * Simply extract the archive.
188 http://code.google.com/p/protobuf/downloads/list
189 * Open vsprojects/protobuf.sln with Visual Studio and build the whole
192 Then run cmake-gui and specify the path to the libphonenumber's cpp directory
193 and its build directory which must be created (e.g. cpp/build).
195 When clicking on "Configure", specify the appropriate Visual Studio version
198 Then CMake will need your help to locate the dependencies. You will have to set
199 the following variables (this example assumes that you extracted the
200 dependencies to C:/).
202 GTEST_INCLUDE_DIR C:/gtest-1.6.0/include
203 GTEST_LIB C:/gtest-1.6.0/msvc/gtest-md/Release/gtest.lib
205 ICU_I18N_INCLUDE_DIR C:/icu/include
206 ICU_I18N_LIB C:/icu/lib/icuin.lib
208 ICU_UC_INCLUDE_DIR C:/icu/include
209 ICU_UC_LIB C:/icu/lib/icuuc.lib
211 PROTOBUF_INCLUDE_DIR C:/protobuf-2.4.1/src
212 PROTOBUF_LIB C:/protobuf-2.4.1/vsprojects/Release/libprotobuf.lib
213 PROTOC_BIN C:/protobuf-2.4.1/vsprojects/Release/protoc.exe
215 Then you can click on "Configure" again. CMake should have located all the
217 Then click on "Generate" to generate the appropriate Visual Studio project.
218 Then open cpp/build/libphonenumber.sln with Visual Studio and build the INSTALL
221 As a result the library's headers and binaries should have been installed to
222 C:/Program Files/libphonenumber/.
223 Note that this path can be set by overriding the CMAKE_INSTALL_PREFIX variable
226 Supported build parameters
227 --------------------------
228 Build parameters can be specified invoking CMake with '-DKEY=VALUE' or using a
229 CMake user interface (ccmake or cmake-gui).
231 USE_ICU_REGEXP = ON | OFF [ON] -- Use ICU regexp engine.
232 USE_LITE_METADATA = ON | OFF [OFF] -- Generates smaller metadata that doesn't
233 include example numbers.
234 USE_RE2 = ON | OFF [OFF] -- Use RE2.
235 USE_STD_MAP = ON | OFF [OFF] -- Force the use of std::map.