David Beaumont | 14dc215 | 2014-11-28 15:49:34 +0000 | [diff] [blame] | 1 | C++ version of the libphonenumber project |
| 2 | ========================================= |
Philip Liard | a3802a3 | 2011-02-22 08:04:03 +0000 | [diff] [blame] | 3 | |
David Beaumont | 14dc215 | 2014-11-28 15:49:34 +0000 | [diff] [blame] | 4 | This library is a port of the Java version. |
Philip Liard | a3802a3 | 2011-02-22 08:04:03 +0000 | [diff] [blame] | 5 | |
| 6 | This project uses some third-party code: |
Philippe Liard | ae165b1 | 2011-11-30 10:42:30 +0000 | [diff] [blame] | 7 | - src/phonenumbers/utf/ sources come from lib9 which is also used in Go. |
Philip Liard | a3802a3 | 2011-02-22 08:04:03 +0000 | [diff] [blame] | 8 | |
Philippe Liard | b9a0d78 | 2011-12-07 14:52:33 +0000 | [diff] [blame] | 9 | |
David Beaumont | 14dc215 | 2014-11-28 15:49:34 +0000 | [diff] [blame] | 10 | Installing the library on GNU/Linux |
| 11 | ----------------------------------- |
| 12 | In recent Debian-based distributions you may be able to simply install the |
| 13 | libphonenumber library directly. |
| 14 | |
| 15 | Installing the binary packages: |
| 16 | - Use this if you just need to use or link against the library: |
Daco Harkes | 72d1470 | 2021-03-02 18:34:09 +0100 | [diff] [blame] | 17 | $ sudo apt-get install libphonenumber8 libphonenumber-dev |
David Beaumont | 14dc215 | 2014-11-28 15:49:34 +0000 | [diff] [blame] | 18 | |
| 19 | Installing the source package: |
| 20 | - Use this if you wish to develop or debug the library: |
| 21 | $ sudo apt-get source libphonenumber |
| 22 | |
| 23 | The latest packages can be found on the Debian packages site: |
| 24 | https://packages.debian.org/search?searchon=names&keywords=libphonenumber |
| 25 | |
| 26 | |
| 27 | Manually installing the library on GNU/Linux |
| 28 | -------------------------------------------- |
| 29 | You should only need these instructions if the above instructions do not work. |
| 30 | |
| 31 | The example command lines below assume that you have a Debian-based GNU/Linux |
| 32 | distribution. Other distributions and packaging systems will differ. |
| 33 | |
| 34 | Quickstart: |
Felix Yan | 9040229 | 2017-05-12 03:21:38 -0500 | [diff] [blame] | 35 | - In recent Debian-based distributions, it should be sufficient to run: |
David Beaumont | 14dc215 | 2014-11-28 15:49:34 +0000 | [diff] [blame] | 36 | $ sudo apt-get install \ |
| 37 | cmake cmake-curses-gui libprotobuf-dev libgtest-dev libre2-dev \ |
Keghani Kouzoujian | 5415fca | 2016-04-01 10:30:00 +0200 | [diff] [blame] | 38 | libicu-dev libboost-dev libboost-thread-dev libboost-system-dev \ |
| 39 | protobuf-compiler |
David Beaumont | 14dc215 | 2014-11-28 15:49:34 +0000 | [diff] [blame] | 40 | |
| 41 | If any of these packages fails to install correctly, follow the instructions |
| 42 | in the appropriate section below. |
| 43 | |
Philip Liard | a3802a3 | 2011-02-22 08:04:03 +0000 | [diff] [blame] | 44 | Requirements: |
| 45 | - CMake build system |
| 46 | http://www.cmake.org |
| 47 | |
David Beaumont | 14dc215 | 2014-11-28 15:49:34 +0000 | [diff] [blame] | 48 | Installation: |
Philip Liard | a3802a3 | 2011-02-22 08:04:03 +0000 | [diff] [blame] | 49 | $ sudo apt-get install cmake |
| 50 | |
David Beaumont | 1b31d8e | 2012-07-19 13:31:07 +0000 | [diff] [blame] | 51 | Additionally it is recommended you install the ccmake configuration tool: |
| 52 | $ sudo apt-get install cmake-curses-gui |
| 53 | |
Philip Liard | ff0ef17 | 2011-03-04 08:43:24 +0000 | [diff] [blame] | 54 | - Protocol Buffers |
lararennie | 1a513f6 | 2018-08-21 10:07:40 +0200 | [diff] [blame] | 55 | http://github.com/google/protobuf/ |
penmetsaa | 859b00d | 2019-10-07 08:37:43 +0000 | [diff] [blame] | 56 | Version 3.6.1 or more recent is required (this is available by default for |
David Beaumont | 14dc215 | 2014-11-28 15:49:34 +0000 | [diff] [blame] | 57 | recent Debian-based GNU/Linux distributions). |
Philip Liard | ff0ef17 | 2011-03-04 08:43:24 +0000 | [diff] [blame] | 58 | |
David Beaumont | 14dc215 | 2014-11-28 15:49:34 +0000 | [diff] [blame] | 59 | You can check which version is available: |
Keghani Kouzoujian | 40f3fe0 | 2016-03-31 16:06:54 +0200 | [diff] [blame] | 60 | $ apt-cache show libprotobuf-dev |
David Beaumont | 14dc215 | 2014-11-28 15:49:34 +0000 | [diff] [blame] | 61 | Package: libprotobuf-dev |
| 62 | Source: protobuf |
penmetsaa | 859b00d | 2019-10-07 08:37:43 +0000 | [diff] [blame] | 63 | Version: 3.6.1-9ubuntu1 <-- This must be >= 3.6.1 |
David Beaumont | 14dc215 | 2014-11-28 15:49:34 +0000 | [diff] [blame] | 64 | ... |
| 65 | |
| 66 | Installation: |
Philip Liard | ff0ef17 | 2011-03-04 08:43:24 +0000 | [diff] [blame] | 67 | $ sudo apt-get install libprotobuf-dev |
| 68 | |
Shaopeng Jia | 4628c70 | 2011-03-24 09:10:31 +0000 | [diff] [blame] | 69 | Note: if your GNU/Linux distribution doesn't provide the needed package, |
| 70 | please download and install it manually: |
penmetsaa | 859b00d | 2019-10-07 08:37:43 +0000 | [diff] [blame] | 71 | More details can be found at its official page: |
| 72 | https://github.com/protocolbuffers/protobuf |
Shaopeng Jia | 4628c70 | 2011-03-24 09:10:31 +0000 | [diff] [blame] | 73 | |
Philip Liard | ff0ef17 | 2011-03-04 08:43:24 +0000 | [diff] [blame] | 74 | - Google Test |
lararennie | 1a513f6 | 2018-08-21 10:07:40 +0200 | [diff] [blame] | 75 | http://github.com/google/googletest |
Philip Liard | ff0ef17 | 2011-03-04 08:43:24 +0000 | [diff] [blame] | 76 | |
David Beaumont | 14dc215 | 2014-11-28 15:49:34 +0000 | [diff] [blame] | 77 | Installation: |
Philip Liard | ff0ef17 | 2011-03-04 08:43:24 +0000 | [diff] [blame] | 78 | $ sudo apt-get install libgtest-dev |
| 79 | |
Philip Liard | a3802a3 | 2011-02-22 08:04:03 +0000 | [diff] [blame] | 80 | - RE2 |
lararennie | 1a513f6 | 2018-08-21 10:07:40 +0200 | [diff] [blame] | 81 | http://github.com/google/re2 |
Philip Liard | a3802a3 | 2011-02-22 08:04:03 +0000 | [diff] [blame] | 82 | |
David Beaumont | 14dc215 | 2014-11-28 15:49:34 +0000 | [diff] [blame] | 83 | Installation: |
Philip Liard | a3802a3 | 2011-02-22 08:04:03 +0000 | [diff] [blame] | 84 | $ sudo apt-get install libre2-dev |
| 85 | |
David Beaumont | 14dc215 | 2014-11-28 15:49:34 +0000 | [diff] [blame] | 86 | Note that some distributions (notably Ubuntu 10.4) may not include this, |
| 87 | so you might need to download and install it manually. |
Philip Liard | a3802a3 | 2011-02-22 08:04:03 +0000 | [diff] [blame] | 88 | |
David Beaumont | 14dc215 | 2014-11-28 15:49:34 +0000 | [diff] [blame] | 89 | Find and download the Debian packages for your system. For example: |
| 90 | http://packages.ubuntu.com/utopic/libre2-1 |
| 91 | http://packages.ubuntu.com/utopic/libre2-dev |
Philip Liard | a3802a3 | 2011-02-22 08:04:03 +0000 | [diff] [blame] | 92 | |
David Beaumont | 14dc215 | 2014-11-28 15:49:34 +0000 | [diff] [blame] | 93 | You need to download both the libre2-dev and libre2-1 packages. |
| 94 | Once downloaded, install them with: |
| 95 | $ sudo dpkg -i libre2*.deb |
| 96 | |
| 97 | If you want to install it from source, it's available via Mercurial at: |
| 98 | https://re2.googlecode.com/hg |
| 99 | however precise instructions on building and installing are outside the |
| 100 | scope of this document. |
Philip Liard | a3802a3 | 2011-02-22 08:04:03 +0000 | [diff] [blame] | 101 | |
Philip Liard | 8e7e1b9 | 2011-03-03 14:35:27 +0000 | [diff] [blame] | 102 | - ICU |
David Beaumont | 14dc215 | 2014-11-28 15:49:34 +0000 | [diff] [blame] | 103 | Installation: |
David Beaumont | 1b31d8e | 2012-07-19 13:31:07 +0000 | [diff] [blame] | 104 | $ sudo apt-get install libicu-dev |
| 105 | |
| 106 | Otherwise you need to download the source tarball for the latest version |
| 107 | from: |
| 108 | http://site.icu-project.org/download |
| 109 | And then extract it via: |
David Beaumont | 14dc215 | 2014-11-28 15:49:34 +0000 | [diff] [blame] | 110 | $ tar xzf icu4c-*-src.tgz |
David Beaumont | 1b31d8e | 2012-07-19 13:31:07 +0000 | [diff] [blame] | 111 | |
| 112 | Alternatively you can export the SVN repository to the current directory |
| 113 | via: |
David Beaumont | 14dc215 | 2014-11-28 15:49:34 +0000 | [diff] [blame] | 114 | $ svn export http://source.icu-project.org/repos/icu/icu/tags/release-XX-y-z/ |
David Beaumont | 1b31d8e | 2012-07-19 13:31:07 +0000 | [diff] [blame] | 115 | |
| 116 | Having acquired the latest sources, make and install it via: |
Philip Liard | 6992133 | 2011-06-06 08:15:16 +0000 | [diff] [blame] | 117 | $ cd icu/source |
| 118 | $ ./configure && make && sudo make install |
Philip Liard | 8e7e1b9 | 2011-03-03 14:35:27 +0000 | [diff] [blame] | 119 | |
Gilles Vollant | 00e4f74 | 2020-06-04 16:10:03 +0200 | [diff] [blame] | 120 | - A thread synchronization solution or more recent is required if you need |
| 121 | libphonenumber to be thread-safe. Supported solution are: |
| 122 | - Boost Version 1.40 or more recent |
| 123 | - Posix Thread. Linux or Apple (ios/mac) detection is automatic. On other |
| 124 | Posix environnement, uses -DUSE_POSIX_THREAD = ON |
| 125 | - C++ 2011 (and later) std::mutex. Uses -DUSE_STDMUTEX = ON to enable |
| 126 | automatic C++ 2011 detection (if you prefer Posix or Win32 solution). |
| 127 | - Windows Win32 synchronization API. |
| 128 | |
| 129 | If you access libphonenumber from a single thread, you don't need one of |
| 130 | these solution. |
Philip Liard | 486cbd9 | 2011-06-07 14:41:10 +0000 | [diff] [blame] | 131 | |
| 132 | You can install it very easily on a Debian-based GNU/Linux distribution: |
David Beaumont | 14dc215 | 2014-11-28 15:49:34 +0000 | [diff] [blame] | 133 | $ sudo apt-get install libboost-dev libboost-thread-dev libboost-system-dev |
Philip Liard | 486cbd9 | 2011-06-07 14:41:10 +0000 | [diff] [blame] | 134 | |
| 135 | Note: Boost Thread is the only library needed at link time. |
Philip Liard | a3802a3 | 2011-02-22 08:04:03 +0000 | [diff] [blame] | 136 | |
David Beaumont | 14dc215 | 2014-11-28 15:49:34 +0000 | [diff] [blame] | 137 | |
penmetsaa | 0c96fbd | 2022-07-19 13:42:03 +0530 | [diff] [blame] | 138 | - abseil-cpp |
| 139 | As this dependency package might not be very common, we are downloading, |
| 140 | building and linking this library as part of the regular build process i.e |
| 141 | part of CMake/Make instructions. If you wish to install this C++ developer |
| 142 | library at your system level and avoid building every time, you can try |
| 143 | below instruction set. |
| 144 | |
| 145 | Installation: |
| 146 | - Official [installation guide](https://abseil.io/docs/cpp/tools/cmake-installs). |
| 147 | Something that we followed in Linux system. |
| 148 | $ git clone https://github.com/abseil/abseil-cpp.git --branch 273292d --single-branch |
| 149 | $ cd abseil-cpp |
| 150 | $ cmake . -DCMAKE_INSTALL_PREFIX="$HOME/lpn-deps" -DCMAKE_POSITION_INDEPENDENT_CODE=ON |
| 151 | $ cmake --build . --target install |
| 152 | - When building libphonenumber library, if abseil-cpp is still getting downloaded and |
| 153 | built, use flags like ```CMAKE_PREFIX_PATH="$HOME/lpn-deps"``` |
| 154 | - Notes: |
| 155 | - We are cloning only a particular version of the abseil-cpp so that we |
| 156 | are not commiting to catch up with new build requirements of that |
| 157 | library. Eg: After the above tag version C++14 is made as minimum |
| 158 | version to build abseil-cpp library. |
| 159 | - libphonenumber is presently using C++11 by default, you can always |
| 160 | change it by passing ```CMAKE_CXX_STANDARD``` flag. |
| 161 | |
David Beaumont | a34ddc9 | 2015-03-06 13:53:07 +0100 | [diff] [blame] | 162 | Building and testing the library |
| 163 | -------------------------------- |
David Beaumont | 1b31d8e | 2012-07-19 13:31:07 +0000 | [diff] [blame] | 164 | $ cd libphonenumber/cpp |
Philip Liard | a3802a3 | 2011-02-22 08:04:03 +0000 | [diff] [blame] | 165 | $ mkdir build |
| 166 | $ cd build |
Philippe Liard | 7b30af6 | 2011-09-21 17:43:54 +0000 | [diff] [blame] | 167 | $ cmake .. |
Philip Liard | a3802a3 | 2011-02-22 08:04:03 +0000 | [diff] [blame] | 168 | $ make |
David Beaumont | a34ddc9 | 2015-03-06 13:53:07 +0100 | [diff] [blame] | 169 | $ ./libphonenumber_test |
David Beaumont | 14dc215 | 2014-11-28 15:49:34 +0000 | [diff] [blame] | 170 | |
Keghani Kouzoujian | 40f3fe0 | 2016-03-31 16:06:54 +0200 | [diff] [blame] | 171 | |
| 172 | Manually installing the library on Mac |
| 173 | -------------------------------------- |
| 174 | |
| 175 | You can easily install dependencies on Mac using a package manager. In these |
| 176 | instructions we use Homebrew (http://brew.sh). |
| 177 | |
| 178 | Install Homebrew package manager and use it to install dependencies: |
| 179 | $ /usr/bin/ruby -e "$(curl -fsSL \ |
| 180 | https://raw.githubusercontent.com/Homebrew/install/master/install)" |
| 181 | $ brew install boost cmake icu4c pkg-config protobuf wget |
| 182 | |
| 183 | See https://github.com/Homebrew/homebrew/issues/14099 - homebrew does not have |
| 184 | gtest. We don't need to install gtest, we only copy sources. For example: |
| 185 | $ mkdir ~/googletest_clone |
| 186 | $ cd ~/googletest_clone |
| 187 | $ git clone https://github.com/google/googletest.git |
| 188 | |
| 189 | Get the libphonenumber source. For example: |
| 190 | $ mkdir ~/libphonenumber_clone |
| 191 | $ cd ~/libphonenumber_clone |
penmetsaa | c4cd5e0 | 2019-07-18 00:11:30 +0000 | [diff] [blame] | 192 | $ git clone https://github.com/google/libphonenumber.git |
Keghani Kouzoujian | 40f3fe0 | 2016-03-31 16:06:54 +0200 | [diff] [blame] | 193 | |
| 194 | Build and test the library: |
| 195 | $ cd libphonenumber/cpp |
| 196 | $ mkdir build |
| 197 | $ cd build |
Keghani Kouzoujian | d90cd60 | 2016-04-01 11:19:39 +0200 | [diff] [blame] | 198 | Replace XXX in the commands below with the appropriate version number: |
Keghani Kouzoujian | 40f3fe0 | 2016-03-31 16:06:54 +0200 | [diff] [blame] | 199 | $ cmake \ |
| 200 | -DGTEST_SOURCE_DIR=~/googletest_clone/googletest/googletest/ \ |
| 201 | -DGTEST_INCLUDE_DIR=~/googletest_clone/googletest/googletest/include/ \ |
| 202 | -DICU_UC_INCLUDE_DIR=/usr/local/Cellar/icu4c/XXX/include/ \ |
| 203 | -DICU_UC_LIB=/usr/local/Cellar/icu4c/XXX/lib/libicuuc.dylib \ |
| 204 | -DICU_I18N_INCLUDE_DIR=/usr/local/Cellar/icu4c/XXX/include/ \ |
| 205 | -DICU_I18N_LIB=/usr/local/Cellar/icu4c/XXX/lib/libicui18n.dylib \ |
| 206 | -DUSE_STD_MAP=ON \ |
| 207 | .. |
| 208 | $ make |
| 209 | $ ./libphonenumber_test |
| 210 | |
| 211 | Optional: Deleting & uninstalling everything again: |
| 212 | $ cd |
| 213 | $ rm -rf ~/libphonenumber_clone ~/googletest_clone |
| 214 | |
| 215 | openssl is a dependency of wget and installed with it by Homebrew. If you had |
| 216 | openssl before installing wget don't uninstall here. |
| 217 | $ brew uninstall boost cmake icu4c openssl pkg-config protobuf wget |
| 218 | |
| 219 | $ /usr/bin/ruby -e "$(curl -fsSL \ |
| 220 | https://raw.githubusercontent.com/Homebrew/install/master/uninstall)" |
| 221 | |
| 222 | Homebrew will have changed permissions at installation. See output of previous |
| 223 | command for how to change them back, for example: |
| 224 | $ sudo chmod 0755 /usr/local |
| 225 | $ sudo chgrp wheel /usr/local |
| 226 | |
| 227 | |
David Beaumont | 14dc215 | 2014-11-28 15:49:34 +0000 | [diff] [blame] | 228 | Troubleshooting CMake via ccmake |
| 229 | -------------------------------- |
David Beaumont | 1b31d8e | 2012-07-19 13:31:07 +0000 | [diff] [blame] | 230 | Follow these instructions if the build steps above don't work for you. |
| 231 | |
| 232 | - Incorrect protocol buffer library issues |
| 233 | If the build process complains that the version of protoc being used is too |
| 234 | old or that it cannot find the correct libprotobuf library, you may need to |
| 235 | change the library path of the project. |
| 236 | |
| 237 | This issue should typically only occur in cases where you have two (or more) |
| 238 | versions of the protocol buffer libraries installed on your system. This |
| 239 | step assumes that you have already manually downloaded and installed the |
| 240 | protocol buffer libraries into /usr/local (as described above). |
| 241 | |
| 242 | To make cmake use the manually installed version of the protocol buffer |
| 243 | libraries, install cmake-curses-gui and use ccmake as follows. |
| 244 | |
| 245 | From within libphonenumber/cpp/build: |
| 246 | $ ccmake . |
| 247 | |
| 248 | You should set the following values: |
| 249 | PROTOBUF_INCLUDE_DIR /usr/local/include |
Josh Cockrell | 067d7d0 | 2018-08-30 09:50:52 -0700 | [diff] [blame] | 250 | PROTOBUF_LIB /usr/local/lib/libprotobuf.dylib |
David Beaumont | 1b31d8e | 2012-07-19 13:31:07 +0000 | [diff] [blame] | 251 | PROTOC_BIN /usr/local/bin/protoc |
| 252 | |
| 253 | Now press 'c' then 'g' to configure the new parameters and exit ccmake. |
| 254 | Finally regenerate the make files and rebuild via: |
| 255 | $ cmake .. |
| 256 | $ make |
| 257 | |
| 258 | - Protoc binary not executing properly |
| 259 | If you still have issues with the protoc binary tool in /usr/local/bin not |
| 260 | running correctly (cannot find libprotobuf.so.x) then you may need to |
| 261 | configure the LD_LIBRARY_PATH. To do this, as a superuser, add the following |
| 262 | file: |
| 263 | /etc/ld.so.conf.d/libprotobuf.conf |
| 264 | |
| 265 | with the contents: |
| 266 | # Use the manually installed version of the protocol buffer libraries. |
| 267 | /usr/local/lib |
| 268 | |
| 269 | And then run: |
| 270 | $ sudo chmod 644 /etc/ld.so.conf.d/libprotobuf.conf |
| 271 | $ sudo ldconfig |
| 272 | |
| 273 | - Incorrect ICU library issues |
| 274 | Similar to the protocol buffer library issue above, it is possible that your |
| 275 | build may fail if you have two conflicting versions of the ICU libraries |
| 276 | installed on your system. This step assumes that you have already manually |
| 277 | downloaded and installed a recent version of the ICU libraries into |
| 278 | /usr/local. |
| 279 | |
| 280 | Install and run the ccmake tool (as described above) and set the following |
| 281 | values: |
| 282 | ICU_I18N_INCLUDE_DIR /usr/local/include |
| 283 | ICU_I18N_LIB /usr/local/lib/libicui18n.so |
| 284 | ICU_UC_INCLUDE_DIR /usr/local/include |
| 285 | ICU_UC_LIB /usr/local/lib/libicuuc.so |
| 286 | |
| 287 | Now press 'c' then 'g' to configure the new parameters and exit ccmake. |
| 288 | Finally regenerate the make files and rebuild via: |
| 289 | $ cmake .. |
| 290 | $ make |
Philippe Liard | b9a0d78 | 2011-12-07 14:52:33 +0000 | [diff] [blame] | 291 | |
Keghani Kouzoujian | 40f3fe0 | 2016-03-31 16:06:54 +0200 | [diff] [blame] | 292 | |
Philippe Liard | b9a0d78 | 2011-12-07 14:52:33 +0000 | [diff] [blame] | 293 | Building the library on Windows (Visual Studio) |
| 294 | ----------------------------------------------- |
Keghani Kouzoujian | ab5df26 | 2017-03-13 14:35:37 +0100 | [diff] [blame] | 295 | We recommend that libphonenumber on Windows be built with Visual Studio 2015 |
| 296 | Update 2 (https://www.visualstudio.com/en-us/news/releasenotes/vs2015-update2-vs) |
| 297 | or later. |
| 298 | |
| 299 | This enables support of plain UTF-8 source files, for which you also need to specify |
| 300 | the /utf-8 option in build files; see "New Options in VS2015 Update 2" at |
| 301 | https://blogs.msdn.microsoft.com/vcblog/2016/02/22/new-options-for-managing-character-sets-in-the-microsoft-cc-compiler/, |
| 302 | or a Chrome patch for an example: |
| 303 | https://codereview.chromium.org/2488853002/diff/80001/build/config/compiler/BUILD.gn |
| 304 | |
| 305 | Without this version and the option, your compilation will have warnings when |
| 306 | setting the codepage for non-Unicode applications on Windows to one of the CJK |
| 307 | code pages, since libphonenumber has UTF-8 strings in source files. While these |
| 308 | are only comments (as opposed to string literals) the warnings can be |
| 309 | suppressed, but we reserve the right to introduce UTF-8 string literals. |
| 310 | |
Philippe Liard | b9a0d78 | 2011-12-07 14:52:33 +0000 | [diff] [blame] | 311 | The library was tested with Visual Studio 2010. |
| 312 | |
| 313 | You will need to manually fetch and install the following dependencies: |
| 314 | - CMake (tested with v2.8.6): |
| 315 | http://cmake.org/cmake/resources/software.html |
| 316 | * Download and install the Win32 installer. |
| 317 | |
| 318 | - Boost (tested with v1.44) from BoostPro: |
| 319 | http://www.boostpro.com/download/ |
| 320 | * Select all the variants and Boost DateTime and Boost Thread during the |
| 321 | installation process. |
Philippe Liard | 9f0d77e | 2013-04-30 12:08:05 +0000 | [diff] [blame] | 322 | See Linux instructions for information about thread-safety. |
Philippe Liard | b9a0d78 | 2011-12-07 14:52:33 +0000 | [diff] [blame] | 323 | |
| 324 | - GTest (tested with v1.6.0): |
| 325 | http://code.google.com/p/googletest/downloads/list |
| 326 | * Open msvc/gtest-md.sln with Visual Studio and build the whole solution. |
| 327 | |
| 328 | - ICU (MSVC binaries, tested with v4.8.1): |
| 329 | http://site.icu-project.org/download/48#ICU4C-Download |
| 330 | * Simply extract the archive. |
| 331 | |
| 332 | - Protocol Buffers: |
| 333 | http://code.google.com/p/protobuf/downloads/list |
| 334 | * Open vsprojects/protobuf.sln with Visual Studio and build the whole |
| 335 | solution. |
| 336 | |
| 337 | Then run cmake-gui and specify the path to the libphonenumber's cpp directory |
| 338 | and its build directory which must be created (e.g. cpp/build). |
| 339 | |
| 340 | When clicking on "Configure", specify the appropriate Visual Studio version |
| 341 | (tested with 2010). |
| 342 | |
| 343 | Then CMake will need your help to locate the dependencies. You will have to set |
| 344 | the following variables (this example assumes that you extracted the |
| 345 | dependencies to C:/). |
| 346 | |
| 347 | GTEST_INCLUDE_DIR C:/gtest-1.6.0/include |
| 348 | GTEST_LIB C:/gtest-1.6.0/msvc/gtest-md/Release/gtest.lib |
| 349 | |
| 350 | ICU_I18N_INCLUDE_DIR C:/icu/include |
| 351 | ICU_I18N_LIB C:/icu/lib/icuin.lib |
| 352 | |
| 353 | ICU_UC_INCLUDE_DIR C:/icu/include |
| 354 | ICU_UC_LIB C:/icu/lib/icuuc.lib |
| 355 | |
penmetsaa | 859b00d | 2019-10-07 08:37:43 +0000 | [diff] [blame] | 356 | PROTOBUF_INCLUDE_DIR C:/protobuf-3.6.1/src |
| 357 | PROTOBUF_LIB C:/protobuf-3.6.1/vsprojects/Release/libprotobuf.lib |
| 358 | PROTOC_BIN C:/protobuf-3.6.1/vsprojects/Release/protoc.exe |
Philippe Liard | b9a0d78 | 2011-12-07 14:52:33 +0000 | [diff] [blame] | 359 | |
| 360 | Then you can click on "Configure" again. CMake should have located all the |
| 361 | dependencies. |
| 362 | Then click on "Generate" to generate the appropriate Visual Studio project. |
| 363 | Then open cpp/build/libphonenumber.sln with Visual Studio and build the INSTALL |
| 364 | target. |
| 365 | |
| 366 | As a result the library's headers and binaries should have been installed to |
| 367 | C:/Program Files/libphonenumber/. |
| 368 | Note that this path can be set by overriding the CMAKE_INSTALL_PREFIX variable |
| 369 | with cmake-gui. |
| 370 | |
Keghani Kouzoujian | 40f3fe0 | 2016-03-31 16:06:54 +0200 | [diff] [blame] | 371 | |
Philippe Liard | b9a0d78 | 2011-12-07 14:52:33 +0000 | [diff] [blame] | 372 | Supported build parameters |
| 373 | -------------------------- |
Philip Liard | b36c48f | 2011-05-09 15:04:24 +0000 | [diff] [blame] | 374 | Build parameters can be specified invoking CMake with '-DKEY=VALUE' or using a |
| 375 | CMake user interface (ccmake or cmake-gui). |
| 376 | |
Philippe Liard | b8a13bf | 2013-05-07 12:59:58 +0000 | [diff] [blame] | 377 | USE_ALTERNATE_FORMATS = ON | OFF [ON] -- Use alternate formats for the phone |
| 378 | number matcher. |
| 379 | USE_BOOST = ON | OFF [ON] -- Use Boost. This is only needed in |
Philippe Liard | c2f2752 | 2013-06-17 11:53:01 +0000 | [diff] [blame] | 380 | multi-threaded environments that |
| 381 | are not Linux and Mac. |
| 382 | Libphonenumber relies on Boost for |
Gilles Vollant | 00e4f74 | 2020-06-04 16:10:03 +0200 | [diff] [blame] | 383 | non-POSIX, non-Windows and non-C++ 2011 |
Philippe Liard | c2f2752 | 2013-06-17 11:53:01 +0000 | [diff] [blame] | 384 | multi-threading. |
Philippe Liard | b8a13bf | 2013-05-07 12:59:58 +0000 | [diff] [blame] | 385 | USE_ICU_REGEXP = ON | OFF [ON] -- Use ICU regexp engine. |
| 386 | USE_LITE_METADATA = ON | OFF [OFF] -- Generates smaller metadata that |
| 387 | doesn't include example numbers. |
Gilles Vollant | 00e4f74 | 2020-06-04 16:10:03 +0200 | [diff] [blame] | 388 | USE_POSIX_THREAD = ON | OFF [OFF] -- Use Posix thread for multi-threading. |
Philippe Liard | b8a13bf | 2013-05-07 12:59:58 +0000 | [diff] [blame] | 389 | USE_RE2 = ON | OFF [OFF] -- Use RE2. |
| 390 | USE_STD_MAP = ON | OFF [OFF] -- Force the use of std::map. |
Gilles Vollant | 00e4f74 | 2020-06-04 16:10:03 +0200 | [diff] [blame] | 391 | USE_STDMUTEX = ON | OFF [OFF] -- Detect and use C++2011 for multi-threading. |
Gilles Vollant | 59329d0 | 2020-06-12 12:05:05 +0200 | [diff] [blame] | 392 | REGENERATE_METADATA = ON | OFF [ON] -- When this is set to OFF it will skip |
| 393 | regenerating the metadata with |
| 394 | BuildMetadataCppFromXml. Since the |
| 395 | metadata is included in the source |
| 396 | tree anyway, it is beneficial for |
| 397 | packagers to turn this OFF: it saves |
| 398 | some time, and it also makes it |
| 399 | unnecessary to have java in the build |
| 400 | environment. |